From a35c32a0422c4911f0c356eabf9da2df93fb4e34 Mon Sep 17 00:00:00 2001 From: kbellouard Date: Tue, 8 Jul 2025 10:57:24 +0200 Subject: [PATCH] feat: ci/cd deployment --- .github/workflows/ci-cd.yml | 18 -------------- .github/workflows/deploy.yml | 46 ++++++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+), 18 deletions(-) create mode 100644 .github/workflows/deploy.yml diff --git a/.github/workflows/ci-cd.yml b/.github/workflows/ci-cd.yml index 22da6be..7003f8d 100644 --- a/.github/workflows/ci-cd.yml +++ b/.github/workflows/ci-cd.yml @@ -1,9 +1,6 @@ name: CI/CD Pipeline on: - push: - branches: - - main pull_request: branches: - main @@ -102,18 +99,3 @@ jobs: # - name: Run E2E Tests # run: | # echo "Running E2E tests..." - - deploy: - runs-on: ubuntu-latest - # needs: [sonarqube, test, owasp-zap, e2e-tests] - needs: [sonarqube, test, owasp-zap] - steps: - - uses: actions/checkout@v3 - - name: Set up JDK 21 - uses: actions/setup-java@v3 - with: - java-version: "21" - distribution: "temurin" - - name: Deploy - run: | - echo "Deploying application..." diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000..458051b --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,46 @@ +name: Deployment pipeline + +on: + push: + branches: + - main + +env: + REGISTRY: ghcr.io + IMAGE_NAME: sanalyz-api + +jobs: + build-and-push-images: + runs-on: ubuntu-latest + permissions: + packages: write + contents: read + attestations: write + id-token: write + steps: + - uses: actions/checkout@v4 + - name: Log in to the Container registry + uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + - name: Build and push Docker image + id: push + uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4 + with: + context: . + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + - name: Generate artifact attestation + uses: actions/attest-build-provenance@v2 + with: + subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + subject-digest: ${{ steps.push.outputs.digest }} + push-to-registry: true