Update app version #12
Workflow file for this run
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: Build and push Docker image | |
| on: | |
| push: | |
| tags: | |
| - 'v*' | |
| workflow_dispatch: { } | |
| jobs: | |
| build-and-push: | |
| runs-on: ubuntu-latest | |
| environment: build-production | |
| permissions: | |
| contents: read | |
| packages: write | |
| id-token: write | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| - name: Set up QEMU | |
| uses: docker/setup-qemu-action@v3 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Log in to Docker Hub | |
| uses: docker/login-action@v3 | |
| with: | |
| username: ${{ vars.DOCKERHUB_USERNAME }} | |
| password: ${{ secrets.DOCKERHUB_TOKEN }} | |
| - name: Define tags for the Docker image | |
| id: define_tags | |
| env: | |
| DOCKERHUB_REPO: ${{ vars.DOCKERHUB_REPO }} | |
| run: | | |
| if [[ "$GITHUB_REF_NAME" == v* ]]; then | |
| # Strip the 'v' prefix with Bash expansion | |
| TAGS="${DOCKERHUB_REPO}:${GITHUB_REF_NAME#v}" | |
| elif [[ "$GITHUB_REF" == refs/heads/* ]]; then | |
| BRANCH_NAME="$GITHUB_REF_NAME" | |
| DATE=$(date +%Y%m%d%H%M) | |
| TAGS="${DOCKERHUB_REPO}:build-${DATE}-${BRANCH_NAME}" | |
| else | |
| TAGS="${DOCKERHUB_REPO}:$GITHUB_REF_NAME" | |
| fi | |
| LATEST_TAG=$(curl -s https://api.github.com/repos/${{ github.repository }}/releases/latest \ | |
| | jq -r .tag_name) | |
| if [ "$LATEST_TAG" = "$GITHUB_REF_NAME" ]; then | |
| TAGS="${TAGS},${DOCKERHUB_REPO}:latest" | |
| fi | |
| # Export the tags for later steps | |
| echo "tags=$TAGS" >> $GITHUB_OUTPUT | |
| shell: bash | |
| - name: Build and push | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: . | |
| file: ./Dockerfile.build | |
| platforms: linux/amd64, linux/arm64 | |
| push: true | |
| tags: ${{ steps.define_tags.outputs.tags }} | |
| cache-from: type=registry,ref=${{ vars.DOCKERHUB_REPO }}:cache | |
| cache-to: type=registry,ref=${{ vars.DOCKERHUB_REPO }}:cache,mode=max |