Skip to content

Commit 6b0faba

Browse files
committed
feat: use codeql-ci-app for auth instead of pat
1 parent f6d69bd commit 6b0faba

1 file changed

Lines changed: 15 additions & 4 deletions

File tree

.github/workflows/integration-tests.yml

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,17 @@ jobs:
1010
runs-on: ubuntu-latest
1111
timeout-minutes: 30
1212
steps:
13+
- name: Generate CI token
14+
id: github-ci-app-token
15+
uses: actions/create-github-app-token@bcd2ba49218906704ab6c1aa796996da409d3eb1
16+
with:
17+
client-id: ${{ vars.CODEQL_CI_APP_CLIENT_ID }}
18+
owner: github
19+
permission-contents: write
20+
permission-actions: read
21+
private-key: ${{ secrets.CODEQL_CI_APP_PRIVATE_KEY }}
22+
repositories: codeql-variant-analysis-action
23+
1324
- name: Trigger variant analysis
1425
id: trigger
1526
run: |
@@ -35,7 +46,7 @@ jobs:
3546
EOF
3647
echo "input.json: $(cat input.json)"
3748
38-
RESPONSE=$(curl --no-progress-meter -H "Authorization: Bearer ${{ secrets.BOT_TOKEN }}" "https://api.github.com/repos/$GITHUB_REPOSITORY/code-scanning/codeql/variant-analyses" -X POST -d @input.json)
49+
RESPONSE=$(curl --no-progress-meter -H "Authorization: Bearer ${{ steps.github-ci-app-token.outputs.token }}" "https://api.github.com/repos/$GITHUB_REPOSITORY/code-scanning/codeql/variant-analyses" -X POST -d @input.json)
3950
echo "Response: $RESPONSE"
4051
4152
ID="$(echo "$RESPONSE" | jq '.id')"
@@ -51,7 +62,7 @@ jobs:
5162
- name: Wait for variant analysis to complete
5263
run: |
5364
while true; do
54-
RESPONSE=$(curl --no-progress-meter -H "Authorization: Bearer ${{ secrets.BOT_TOKEN }}" "https://api.github.com/repos/$GITHUB_REPOSITORY/code-scanning/codeql/variant-analyses/${{ steps.trigger.outputs.variant_analysis_id }}")
65+
RESPONSE=$(curl --no-progress-meter -H "Authorization: Bearer ${{ steps.github-ci-app-token.outputs.token }}" "https://api.github.com/repos/$GITHUB_REPOSITORY/code-scanning/codeql/variant-analyses/${{ steps.trigger.outputs.variant_analysis_id }}")
5566
STATUS="$(echo "$RESPONSE" | jq '.status' -r)"
5667
ACTIONS_WORKFLOW_RUN_ID="$(echo "$RESPONSE" | jq '.actions_workflow_run_id' -r)"
5768
echo "Variant analysis ${{ steps.trigger.outputs.variant_analysis_id }} status: $STATUS"
@@ -68,7 +79,7 @@ jobs:
6879
- name: Validate variant analysis status
6980
id: validate
7081
run: |
71-
RESPONSE=$(curl --no-progress-meter -H "Authorization: Bearer ${{ secrets.BOT_TOKEN }}" "https://api.github.com/repos/$GITHUB_REPOSITORY/code-scanning/codeql/variant-analyses/${{ steps.trigger.outputs.variant_analysis_id }}")
82+
RESPONSE=$(curl --no-progress-meter -H "Authorization: Bearer ${{ steps.github-ci-app-token.outputs.token }}" "https://api.github.com/repos/$GITHUB_REPOSITORY/code-scanning/codeql/variant-analyses/${{ steps.trigger.outputs.variant_analysis_id }}")
7283
echo "Response: $RESPONSE"
7384
echo "Actions workflow URL: $GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$(echo "$RESPONSE" | jq '.actions_workflow_run_id')"
7485
@@ -132,7 +143,7 @@ jobs:
132143
exit 1
133144
fi
134145
135-
ACTIONS_RESPONSE=$(curl --no-progress-meter -H "Authorization: Bearer ${{ secrets.BOT_TOKEN }}" "https://api.github.com/repos/$GITHUB_REPOSITORY/actions/runs/$(echo "$RESPONSE" | jq '.actions_workflow_run_id')")
146+
ACTIONS_RESPONSE=$(curl --no-progress-meter -H "Authorization: Bearer ${{ steps.github-ci-app-token.outputs.token }}" "https://api.github.com/repos/$GITHUB_REPOSITORY/actions/runs/$(echo "$RESPONSE" | jq '.actions_workflow_run_id')")
136147
137148
if [ "$(echo "$ACTIONS_RESPONSE" | jq '.status' -r)" != "completed" ]; then
138149
echo "Actions workflow status is not completed"

0 commit comments

Comments
 (0)