Skip to content

Commit

Permalink
feat: add tag build on release (#107)
Browse files Browse the repository at this point in the history
Co-authored-by: leoguillaume <[email protected]>
  • Loading branch information
leoguillaume and leoguillaumegouv authored Dec 9, 2024
1 parent c40cf9c commit e762c05
Showing 1 changed file with 52 additions and 0 deletions.
52 changes: 52 additions & 0 deletions .github/workflows/build_and_tag.yml
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit e762c05

Please sign in to comment.