Skip to content

Commit e519ca7

Browse files
authored
ci: fix sync-readme-versions (#750)
* fix * fix: ci * ci: use peter-evans/create-pull-request
1 parent ba4f395 commit e519ca7

2 files changed

Lines changed: 22 additions & 12 deletions

File tree

.github/workflows/sync-readme-versions.yml

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ jobs:
1515
runs-on: ubuntu-latest
1616
permissions:
1717
contents: write
18+
pull-requests: write
1819
timeout-minutes: 5
1920
steps:
2021
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd #v6.0.2
@@ -25,10 +26,19 @@ jobs:
2526
node-version: 24
2627
- name: Sync action version references
2728
run: pnpm run sync:readme
29+
env:
30+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2831
- name: Commit and push version reference updates
29-
run: |
30-
git config user.name "github-actions[bot]"
31-
git config user.email "github-actions[bot]@users.noreply.github.com"
32-
git add README.md delete/README.md .github/workflow-templates/deploy.yml .github/workflow-templates/delete.yml
33-
git diff --staged --quiet || git commit -m "docs: update action version references [skip ci]"
34-
git push
32+
uses: peter-evans/create-pull-request@5f6978faf089d4d20b00c7766989d076bb2fc7f1 #v8.1.1
33+
with:
34+
token: ${{ secrets.GITHUB_TOKEN }}
35+
commit-message: 'docs: update action version references [skip ci]'
36+
sign-commits: true
37+
title: 'docs: update action version references'
38+
branch: docs/sync-action-versions
39+
delete-branch: true
40+
add-paths: |
41+
README.md
42+
delete/README.md
43+
.github/workflow-templates/deploy.yml
44+
.github/workflow-templates/delete.yml

bin/sync-readme-versions.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {graphql} from '@/gql/gql.js'
1111
import packageJson from '../package.json' with {type: 'json'}
1212

1313
const GITHUB_GRAPHQL_API = 'https://api.github.com/graphql'
14+
const TOKEN = process.env['GITHUB_TOKEN']
1415

1516
/**
1617
* Replaces all `andykenward/github-actions-cloudflare-pages` action version
@@ -53,14 +54,13 @@ const request = async <TResult, TVariables>(
5354
query: TypedDocumentString<TResult, TVariables>,
5455
variables: TVariables
5556
): Promise<TResult> => {
56-
const token = process.env['GITHUB_TOKEN']
57-
const headers: Record<string, string> = {'Content-Type': 'application/json'}
58-
if (token) headers['authorization'] = `bearer ${token}`
59-
6057
const res = await fetch(GITHUB_GRAPHQL_API, {
6158
method: 'POST',
62-
headers,
63-
body: JSON.stringify({query: query.toString(), variables})
59+
headers: {
60+
authorization: `bearer ${TOKEN}`,
61+
'Content-Type': 'application/json'
62+
},
63+
body: JSON.stringify({query, variables})
6464
})
6565
assert.ok(res.ok, `GitHub API request failed: ${res.status}`)
6666
const {data, errors} = (await res.json()) as {data: TResult; errors?: unknown}

0 commit comments

Comments
 (0)