Build and Push Docker Image on Release #2
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 Release | |
| on: | |
| release: | |
| types: [published] | |
| jobs: | |
| docker: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v3 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Login to DockerHub | |
| uses: docker/login-action@v3 | |
| with: | |
| username: ${{ secrets.DOCKER_HUB_USERNAME }} | |
| password: ${{ secrets.DOCKER_HUB_PASSWORD }} | |
| - name: Extract release tag | |
| id: extract_tag | |
| run: | | |
| echo "tag=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT | |
| - name: Build and push Docker image with release tag | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: . | |
| push: true | |
| tags: backofficeplus/e-invoice-validator:${{ steps.extract_tag.outputs.tag }} | |
| - name: Check if release is not a prerelease | |
| id: is_latest | |
| run: | | |
| if [[ "${{ github.event.release.prerelease }}" == "false" ]]; then | |
| echo "set_latest=true" >> $GITHUB_OUTPUT | |
| else | |
| echo "set_latest=false" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Tag and push latest image if not a prerelease | |
| if: steps.is_latest.outputs.set_latest == 'true' | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: . | |
| push: true | |
| tags: backofficeplus/e-invoice-validator:latest |