Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Write post about workflow_dispatch permissions vs. write access #112

Open
dhermes opened this issue Jun 29, 2024 · 0 comments
Open

Write post about workflow_dispatch permissions vs. write access #112

dhermes opened this issue Jun 29, 2024 · 0 comments

Comments

@dhermes
Copy link
Owner

dhermes commented Jun 29, 2024

https://github.com/orgs/community/discussions/26622

    steps:
      # NOTE: We assume the `gh` CLI is present for the runner image:
      #       https://github.com/actions/runner-images/blob/0f2310415608223eb4141ecdbd1101d307f26b06/images/linux/Ubuntu2204-Readme.md
      - name: Validate workflow dispatch actor is allowed to run this workflow
        if: ${{ github.event_name == 'workflow_dispatch' }}
        env:
          GH_TOKEN: ${{ secrets.TEAM_CHECK_GITHUB_TOKEN }}
        run: |
          ACTOR=${{ github.actor }}
          TEAM=veneer

          MEMBERSHIP_STATE=$(gh api "orgs/acme-org/teams/${TEAM}/memberships/${ACTOR}" --template '{{ .state }}' 2> /dev/null || true)
          if [[ "${MEMBERSHIP_STATE}" != "active" ]]; then
            echo "::debug::MEMBERSHIP_STATE=${MEMBERSHIP_STATE}"
            echo "::error::This workflow cannot be run by @${ACTOR}"
            echo "::error::Only members of the @acme-org/${TEAM} team can run this workflow"
            exit 1
          fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant