From fecff0ab79c886853e0cd3fba918e134dbcbb809 Mon Sep 17 00:00:00 2001 From: gmolveau-anssi <153525332+gmolveau-anssi@users.noreply.github.com> Date: Thu, 24 Oct 2024 15:40:54 +0200 Subject: [PATCH] Trigger a pipeline when a new tag is created --- .github/workflows/ci.yml | 41 ++++++++++++++++++++++++++-------------- 1 file changed, 27 insertions(+), 14 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fb9df8c..1b58def 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -4,6 +4,8 @@ on: push: branches: - master + tags: + - '*' jobs: backend-checks: @@ -58,6 +60,7 @@ jobs: build_and_push: runs-on: ubuntu-latest if: startsWith(github.ref, 'refs/tags/') + needs: [backend-checks, frontend-checks] steps: - uses: actions/checkout@v4 @@ -68,18 +71,28 @@ jobs: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - - name: Docker build the backend docker image - run: | - docker build --target prod --build-arg EURYDICE_VERSION=${GITHUB_REF#refs/tags/} --file ./backend/docker/Dockerfile --tag anssi/eurydice-backend:${GITHUB_REF#refs/tags/} backend + - name: Extract tag name + id: extract_tag + run: echo "TAG_NAME=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV - - name: Docker build the frontend docker image - run: | - docker build --target prod --build-arg EURYDICE_VERSION=${GITHUB_REF#refs/tags/} --file ./frontend/docker/Dockerfile --tag anssi/eurydice-frontend:${GITHUB_REF#refs/tags/} frontend - - - name: Docker push backend docker image - run: | - docker push anssi/eurydice-backend:${GITHUB_REF#refs/tags/} - - - name: Docker push frontend docker image - run: | - docker push anssi/eurydice-frontend:${GITHUB_REF#refs/tags/} + - name: Build and push frontend Docker image + uses: docker/build-push-action@v2 + with: + context: frontend + file: ./frontend/docker/Dockerfile + push: true + tags: anssi/eurydice-frontend:${{ env.TAG_NAME }} + target: prod + build-args: | + EURYDICE_VERSION=${{ env.TAG_NAME }} + + - name: Build and push backend Docker image + uses: docker/build-push-action@v2 + with: + context: backend + file: ./backend/docker/Dockerfile + push: true + tags: anssi/eurydice-backend:${{ env.TAG_NAME }} + target: prod + build-args: | + EURYDICE_VERSION=${{ env.TAG_NAME }}