From e762c05dd8ae0cbd2d7a564311d3888720b0d7ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9o=20Guillaume?= <62661249+leoguillaume@users.noreply.github.com> Date: Mon, 9 Dec 2024 14:42:38 +0100 Subject: [PATCH] feat: add tag build on release (#107) Co-authored-by: leoguillaume --- .github/workflows/build_and_tag.yml | 52 +++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 .github/workflows/build_and_tag.yml diff --git a/.github/workflows/build_and_tag.yml b/.github/workflows/build_and_tag.yml new file mode 100644 index 00000000..30a3e90a --- /dev/null +++ b/.github/workflows/build_and_tag.yml @@ -0,0 +1,52 @@ +name: Build and create release image tag + +on: + release: + types: [published, edited] + +jobs: + build-and-push: + name: Build and push from ${{ github.ref_name }}/${{ github.event.release.tag_name }} + runs-on: ubuntu-latest + env: + APP_IMAGE_NAME: ghcr.io/${{ github.repository }}/app + UI_IMAGE_NAME: ghcr.io/${{ github.repository }}/ui + IMAGE_TAG: ${{ github.event.release.tag_name }} + outputs: + commit_title: ${{ steps.get_head_commit_title.outputs.title }} + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - id: get_head_commit_title + run: echo "title=$(git log --format=%B -n 1 HEAD | head -n 1)" >> $GITHUB_OUTPUT + + - name: Log in to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Build and push app + uses: docker/build-push-action@v6 + with: + context: . + file: ./app/Dockerfile + push: true + tags: ${{ env.APP_IMAGE_NAME }}:${{ env.IMAGE_TAG }} + cache-from: type=gha + cache-to: type=gha,mode=max + + - name: Build and push ui + uses: docker/build-push-action@v6 + with: + context: . + file: ./ui/Dockerfile + push: true + tags: ${{ env.UI_IMAGE_NAME }}:${{ env.IMAGE_TAG }} + cache-from: type=gha + cache-to: type=gha,mode=max