Skip to content

Commit 38fe932

Browse files
committed
Document custom PAT creation
1 parent 3ff1842 commit 38fe932

File tree

4 files changed

+21
-12
lines changed

4 files changed

+21
-12
lines changed

.github/workflows/changelog.yaml

+2-3
Original file line numberDiff line numberDiff line change
@@ -184,9 +184,8 @@ jobs:
184184
git commit --all --message="[changelog] Post-release version bump"
185185
- uses: peter-evans/create-pull-request@v6.0.0
186186
with:
187-
# WORKFLOW_UPDATE_GITHUB_PAT is a custom token created from my user's profile via the
188-
# "Developer Settings > Personal Access Tokens" UI to allow this job to update its own workflows. This is
189-
# only used on the original kdeldycke/workflows repository, hence the fallback to default GitHub token.
187+
# We need custom PAT with workflows permission to hard-code version numbers in URLs in
188+
# .github/workflows/*.yaml files.
190189
token: ${{ secrets.WORKFLOW_UPDATE_GITHUB_PAT || secrets.GITHUB_TOKEN }}
191190
assignees: ${{ github.actor }}
192191
title: >

.github/workflows/docs.yaml

+1-3
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,7 @@ jobs:
3232
run: rm ./typos
3333
- uses: peter-evans/create-pull-request@v6.0.0
3434
with:
35-
# WORKFLOW_UPDATE_GITHUB_PAT is a custom token created from my user's profile via the
36-
# "Developer Settings > Personal Access Tokens" UI to allow this job to update its own workflows. This is
37-
# only used on the original kdeldycke/workflows repository, hence the fallback to default GitHub token.
35+
# We need custom PAT with workflows permissions to fix typos in .github/workflows/*.yaml` files.
3836
token: ${{ secrets.WORKFLOW_UPDATE_GITHUB_PAT || secrets.GITHUB_TOKEN }}
3937
assignees: ${{ github.actor }}
4038
commit-message: "[autofix] Typo"

.github/workflows/release.yaml

+2-4
Original file line numberDiff line numberDiff line change
@@ -199,10 +199,7 @@ jobs:
199199
if: ${{ ! steps.tag_exists.outputs.tag_exists }}
200200
uses: tvdias/github-tagger@v0.0.2
201201
with:
202-
# XXX actionlint triggers this error:
203-
# property "workflow_update_github_pat" is not defined in object type {actions_runner_debug: string;
204-
# actions_step_debug: string; github_token: string; pypi_token: string} [expression]
205-
# See: https://github.com/rhysd/actionlint/issues/148
202+
# XXX We need custom PAT with workflows permissions BECAUSE ??? in .github/workflows/*.yaml files.
206203
repo-token: ${{ secrets.WORKFLOW_UPDATE_GITHUB_PAT || secrets.GITHUB_TOKEN }}
207204
tag: v${{ matrix.current_version }}
208205
commit-sha: ${{ matrix.commit }}
@@ -304,6 +301,7 @@ jobs:
304301
- name: Create GitHub release
305302
uses: softprops/action-gh-release@v1
306303
env:
304+
# XXX We need custom PAT with workflows permissions BECAUSE ??? in .github/workflows/*.yaml files.
307305
GITHUB_TOKEN: ${{ secrets.WORKFLOW_UPDATE_GITHUB_PAT || secrets.GITHUB_TOKEN }}
308306
with:
309307
tag_name: v${{ matrix.current_version }}

readme.md

+16-2
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,22 @@ You will always end up with this kind or errors:
4747
To bypass the limitation, we rely on a custom access token. By convention, we call it `WORKFLOW_UPDATE_GITHUB_PAT`. It will be used, [in place of the default `secrets.GITHUB_TOKEN`](https://github.com/search?q=repo%3Akdeldycke%2Fworkflows%20WORKFLOW_UPDATE_GITHUB_PAT&type=code), in steps in which we need to change the workflow YAML files.
4848

4949
To create this custom `WORKFLOW_UPDATE_GITHUB_PAT`:
50-
- Go to your GitHub user's profile via the `Developer Settings` > `Personal Access Tokens` UI
51-
50+
- From your GitHub user, go to `Settings` > `Developer Settings` > `Personal Access Tokens` > `Fine-grained tokens`
51+
- Click on the `Generate new token` button
52+
- Choose a good token name like `workflow-self-update` to make your intention clear
53+
- Choose `Only select repositories` and the list the repositories in needs of updating their workflow YAML files
54+
- In the `Repository permissions` drop-down, sets:
55+
- `Contents`: `Access: **Read and Write**`
56+
- `Metadata` (mandatory): `Access: **Read-only**`
57+
- `Pull Requests`: `Access: **Read and Write**`
58+
- `Workflows`: `Access: **Read and Write**`
59+
> [!NOTE]
60+
> This is the only place where I can have control over the `Workflows` permission, which is not supported by the `permissions:` parameter in YAML files.
61+
- Now save these parameters and copy the `github_pat_XXXX` secret token
62+
- Got to your repo > `Settings` > `Security` > `Secrets and variables` > `Actions` > `Secrets` > `Repository secrets` and click `New repository secrets`
63+
- Name your secret `WORKFLOW_UPDATE_GITHUB_PAT` and copy the `github_pat_XXXX` token in the `Secret` field
64+
65+
Now re-run your actions and they should be able to update the workflow files in `.github` folder without the `refusing to allow a GitHub App to create or update workflow` error.
5266

5367
## Release management
5468

0 commit comments

Comments
 (0)