Skip to content

Commit e11a539

Browse files
authored
Merge pull request #467 from algorandfoundation/build/bot-token
build: generate and use engineering-ci bot token
2 parents 95b6dc3 + 61191ed commit e11a539

File tree

3 files changed

+248
-301
lines changed

3 files changed

+248
-301
lines changed

.github/workflows/remove-preview-apps.yaml

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,20 @@ jobs:
88
delete-preview-deployment:
99
runs-on: ubuntu-latest
1010
steps:
11+
- name: Generate bot token
12+
uses: actions/create-github-app-token@v1
13+
id: app_token
14+
with:
15+
app-id: ${{ secrets.BOT_ID }}
16+
private-key: ${{ secrets.BOT_SK }}
17+
1118
- name: Get branch name
1219
id: get-branch
1320
run: echo "branch=$(gh pr view $PR_NO --repo $REPO --json headRefName --jq '.headRefName')" >> $GITHUB_OUTPUT
1421
env:
1522
REPO: ${{ github.repository }}
1623
PR_NO: ${{ github.event.pull_request.number }}
17-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
24+
GITHUB_TOKEN: ${{ steps.app_token.outputs.token }}
1825

1926
- name: Delete Cloudflare Pages preview deployments
2027
run: |
@@ -26,24 +33,24 @@ jobs:
2633
bash -c '
2734
PAGE=1
2835
DEPLOYMENT_IDS=""
29-
36+
3037
while true; do
3138
response=$(curl -s -X GET "https://api.cloudflare.com/client/v4/accounts/$ACCOUNT_ID/pages/projects/$PROJECT/deployments?page=$PAGE" \
3239
-H "Authorization: Bearer $AUTH_TOKEN" \
3340
-H "Content-Type: application/json")
34-
41+
3542
page_ids=$(echo "$response" | jq -r --arg DEPLOY_BRANCH "$DEPLOY_BRANCH" '"'"'.result[] | select(.deployment_trigger.metadata.branch == $DEPLOY_BRANCH) | .id'"'"')
3643
DEPLOYMENT_IDS+=" $page_ids"
37-
44+
3845
count=$(echo "$response" | jq -r .result_info.count)
39-
46+
4047
if [ "$count" -eq "0" ]; then
4148
break
4249
fi
43-
50+
4451
PAGE=$((PAGE + 1))
4552
done
46-
53+
4754
echo "$DEPLOYMENT_IDS" | xargs
4855
'
4956
)

0 commit comments

Comments
 (0)