Skip to content

Commit a97d033

Browse files
authored
chore(ci): Replace GH_CQ_BOT PAT with GitHub App tokens (#351)
Replace GH_CQ_BOT PAT with short-lived tokens from the cloudquery-ci GitHub App.
1 parent e0f03ad commit a97d033

File tree

2 files changed

+39
-6
lines changed

2 files changed

+39
-6
lines changed

.github/workflows/gen-client.yml

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,31 @@ jobs:
1010
timeout-minutes: 30
1111
runs-on: ubuntu-latest
1212
steps:
13+
- name: Generate GitHub App token
14+
id: app-token
15+
uses: actions/create-github-app-token@f8d387b68d61c58ab83c6c016672934102569859 # v3
16+
with:
17+
app-id: ${{ secrets.CQ_APP_ID }}
18+
private-key: ${{ secrets.CQ_APP_PRIVATE_KEY }}
19+
permission-contents: write
20+
permission-pull-requests: write
21+
- name: Generate GitHub App token for cloud repo
22+
id: app-token-cloud
23+
uses: actions/create-github-app-token@f8d387b68d61c58ab83c6c016672934102569859 # v3
24+
with:
25+
app-id: ${{ secrets.CQ_APP_ID }}
26+
private-key: ${{ secrets.CQ_APP_PRIVATE_KEY }}
27+
repositories: |
28+
cloud
29+
permission-contents: read
1330
- name: Checkout
1431
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
1532
with:
16-
token: ${{ secrets.GH_CQ_BOT }}
33+
token: ${{ steps.app-token.outputs.token }}
1734

1835
- name: Get Specs File
1936
run: |
20-
curl -H "Authorization: token ${{ secrets.GH_CQ_BOT }}" https://raw.githubusercontent.com/cloudquery/cloud/main/cloud/internal/servergen/spec.json -o spec.json
37+
curl -H "Authorization: token ${{ steps.app-token-cloud.outputs.token }}" https://raw.githubusercontent.com/cloudquery/cloud/main/cloud/internal/servergen/spec.json -o spec.json
2138
2239
- name: Format Specs File
2340
run: |
@@ -38,11 +55,10 @@ jobs:
3855
uses: peter-evans/create-pull-request@c0f553fe549906ede9cf27b5156039d195d2ece0 # v8
3956
with:
4057
# required so the PR triggers workflow runs
41-
token: ${{ secrets.GH_CQ_BOT }}
58+
token: ${{ steps.app-token.outputs.token }}
4259
branch: fix/gen-cloudquery-api
4360
base: main
4461
title: 'fix: Generate CloudQuery Go API Client from `spec.json`'
4562
commit-message: 'fix: Generate CloudQuery Go API Client from `spec.json`'
4663
body: This PR was created by a scheduled workflow to generate the CloudQuery Go API Client from `spec.json`
47-
author: cq-bot <cq-bot@users.noreply.github.com>
4864
labels: automerge

.github/workflows/release-pr.yml

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,27 @@ jobs:
1212
runs-on: ubuntu-latest
1313
timeout-minutes: 10
1414
steps:
15+
- name: Generate GitHub App token
16+
id: app-token
17+
uses: actions/create-github-app-token@f8d387b68d61c58ab83c6c016672934102569859 # v3
18+
with:
19+
app-id: ${{ secrets.CQ_APP_ID }}
20+
private-key: ${{ secrets.CQ_APP_PRIVATE_KEY }}
21+
permission-contents: write
22+
permission-pull-requests: write
23+
- name: Generate GitHub App token for .github repo
24+
id: app-token-github
25+
uses: actions/create-github-app-token@f8d387b68d61c58ab83c6c016672934102569859 # v3
26+
with:
27+
app-id: ${{ secrets.CQ_APP_ID }}
28+
private-key: ${{ secrets.CQ_APP_PRIVATE_KEY }}
29+
repositories: |
30+
.github
31+
permission-actions: write
1532
- uses: googleapis/release-please-action@16a9c90856f42705d54a6fda1823352bdc62cf38 # v4
1633
id: release
1734
with:
18-
token: ${{ secrets.GH_CQ_BOT }}
35+
token: ${{ steps.app-token.outputs.token }}
1936
- name: Parse semver string
2037
if: steps.release.outputs.release_created
2138
id: semver_parser
@@ -34,7 +51,7 @@ jobs:
3451
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8
3552
if: steps.release.outputs.release_created && steps.semver_parser.outputs.prerelease == ''
3653
with:
37-
github-token: ${{ secrets.GH_CQ_BOT }}
54+
github-token: ${{ steps.app-token-github.outputs.token }}
3855
script: |
3956
github.rest.actions.createWorkflowDispatch({
4057
owner: 'cloudquery',

0 commit comments

Comments
 (0)