Permissions in reusable workflows!

  • Below is a "calling" workflow. Notice the Job-based permissions
  • We always need to pass necessary permissions to the reusable workflow
  • The reusable "called" workflow gets the calling "context", including GITHUB_TOKEN and these perms
  • ProTip: Also set required perms in Reusable Workflow. Then, it’ll fail earily if calling doesn’t give them
name: Docker Build
on:
push:
  branches:
    - main
  pull_request:
jobs:
  call-docker-build:
    name: Call Docker Build
    uses: mostlydevops/actions/.github/workflows/reusable-docker-build.yaml@main
    permissions:
      packages: write
      pull-requests: write
    with:
      image-name: ghcr.io/mostlydevops/wordsmith-web
slide 78 (click 0 of 4)