Docker Build on Main and release package #34
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Docker Build on Main and release package | |
| on: | |
| workflow_dispatch: | |
| permissions: | |
| contents: read | |
| packages: write | |
| env: | |
| REGISTRY: ghcr.io | |
| IMAGE_NAME: ${{ github.repository }} | |
| jobs: | |
| docker-build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Login to GitHub Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ${{ env.REGISTRY }} | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Prepare image tag | |
| id: prep | |
| run: | | |
| DATE_TAG="$(date +'%Y%m%d-%H%M%S')" | |
| SHA_TAG="${GITHUB_SHA::7}" | |
| echo "DATE_TAG=$DATE_TAG" >> "$GITHUB_ENV" | |
| echo "SHA_TAG=$SHA_TAG" >> "$GITHUB_ENV" | |
| echo "BUILD_VERSION=main-$DATE_TAG-$SHA_TAG" >> "$GITHUB_ENV" | |
| - name: Stamp frontend package version | |
| run: make stamp-frontend-version VERSION="${{ env.BUILD_VERSION }}" | |
| - name: Stamp backend version | |
| run: make stamp-backend-version VERSION="${{ env.BUILD_VERSION }}" | |
| - name: Build and push main-only-frontend image | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: . | |
| file: ./Dockerfile | |
| target: frontend-runtime | |
| push: true | |
| tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:only-frontend-${{ env.BUILD_VERSION }} | |
| - name: Build and push main-only-backend image | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: . | |
| file: ./Dockerfile | |
| target: backend-runtime | |
| push: true | |
| tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:only-backend-${{ env.BUILD_VERSION }} | |
| - name: Build and push main image | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: . | |
| file: ./Dockerfile | |
| push: true | |
| tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.BUILD_VERSION }} |