Merge pull request #52 from nowsprinting/chore/fix_workflow_permissions #33
This file contains 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: | |
push: | |
branches: | |
- master | |
paths: | |
- .github/workflows/build-image.yml | |
- Dockerfile | |
- entrypoint.sh | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
permissions: {} | |
defaults: | |
run: | |
shell: bash | |
jobs: | |
build-and-push-docker-image: | |
if: github.repository_owner == 'nowsprinting' # Skip on forked repo | |
runs-on: ubuntu-latest | |
timeout-minutes: 5 | |
permissions: | |
contents: read | |
packages: write | |
env: | |
DIFF_PDF_VERSION: 'v0.5.2' | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build and push Docker image | |
uses: docker/build-push-action@v6 | |
with: | |
context: . | |
build-args: REPO_REF=${{ env.DIFF_PDF_VERSION }} | |
push: true | |
labels: org.opencontainers.image.source=https://github.com/${{ github.repository }} | |
tags: | | |
ghcr.io/${{ github.repository_owner }}/diff-pdf:latest | |
ghcr.io/${{ github.repository_owner }}/diff-pdf:${{ env.DIFF_PDF_VERSION }} | |
- uses: 8398a7/action-slack@v3 | |
with: | |
status: ${{ job.status }} | |
fields: repo,message,job,pullRequest | |
mention: here | |
if_mention: failure | |
env: | |
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
if: failure() && github.repository_owner == 'nowsprinting' # Skip public fork, because can not read secrets. |