From 16f5b22c2d498899804fbe773d0e680c6fa145a6 Mon Sep 17 00:00:00 2001 From: Josh Soref <2119212+jsoref@users.noreply.github.com> Date: Fri, 9 Feb 2024 03:22:04 -0500 Subject: [PATCH] Handle running in forks In a fork, the secret is unlikely to be present. By making the project-url conditional on the secret, it'll basically never be set in forks (unless you work on octokit and happen to choose to create a secret to use for the purpose of testing -- which is unlikely). Setting github-token to `github.token` as a fallback means that the workflow will run in forks w/o triggering :x: which is slightly better. Eventually users will still disable it because it's annoying, but only once they manage to create a PR or issue in their fork and it runs and tags it... --- .github/templates/add_to_octokit_project.yml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/templates/add_to_octokit_project.yml b/.github/templates/add_to_octokit_project.yml index 60b2818..aed5cdb 100644 --- a/.github/templates/add_to_octokit_project.yml +++ b/.github/templates/add_to_octokit_project.yml @@ -6,6 +6,10 @@ on: pull_request_target: types: [reopened, opened] +permissions: + issues: write + pull-requests: write + jobs: add-to-project: name: Add issue to project @@ -14,7 +18,7 @@ jobs: steps: - uses: actions/add-to-project@v0.5.0 with: - project-url: https://github.com/orgs/octokit/projects/10 - github-token: ${{ secrets.OCTOKITBOT_PROJECT_ACTION_TOKEN }} + project-url: ${{ secrets.OCTOKITBOT_PROJECT_ACTION_TOKEN && 'https://github.com/orgs/octokit/projects/10' || '' }} + github-token: ${{ secrets.OCTOKITBOT_PROJECT_ACTION_TOKEN || github.token }} labeled: "Status: Stale" label-operator: NOT