Skip to content

Commit

Permalink
Use managed GitHub token for draft dispatch and bundle preview (#181)
Browse files Browse the repository at this point in the history
* Dispatch draft deploys using managed GitHub token

* Use managed GitHub token for bundle preview deploy comments
  • Loading branch information
mlr committed Jan 28, 2025
1 parent 977b474 commit db67713
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
13 changes: 6 additions & 7 deletions .github/workflows/deploy-bundle-preview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ jobs:
if: ${{ success() && github.event.pull_request.number }}
uses: peter-evans/create-or-update-comment@v3
with:
token: ${{ secrets.COMMENT_GITHUB_TOKEN }}
token: ${{ secrets.DOCS_GITHUB_PAT }}
issue-number: ${{ github.event.pull_request.number }}
body: |
UI bundle preview build successful! :white_check_mark:
Expand All @@ -67,7 +67,7 @@ jobs:
if: ${{ failure() && github.event.pull_request.number }}
uses: peter-evans/create-or-update-comment@v3
with:
token: ${{ secrets.COMMENT_GITHUB_TOKEN }}
token: ${{ secrets.DOCS_GITHUB_PAT }}
issue-number: ${{ github.event.pull_request.number }}
body: |
UI bundle preview build failure! :x:
Expand All @@ -79,9 +79,8 @@ jobs:
uses: peter-evans/find-comment@v2
id: fc
with:
token: ${{ secrets.COMMENT_GITHUB_TOKEN }}
token: ${{ secrets.DOCS_GITHUB_PAT }}
issue-number: ${{ github.event.pull_request.number }}
comment-author: 'mlr'
body-includes: UI bundle preview build successful!
direction: last

Expand Down Expand Up @@ -116,7 +115,7 @@ jobs:
sleep 5 # Allow time for build to initiate
build_url=$(curl -s -L \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ secrets.COMMENT_GITHUB_TOKEN }}" \
-H "Authorization: Bearer ${{ secrets.DOCS_GITHUB_PAT }}" \
-H "X-GitHub-Api-Version: 2022-11-28" 'https://api.github.com/repos/${{ github.event.repository.full_name }}/pages/builds/latest' \
| jq -r .url)
echo "url=$build_url" >> $GITHUB_OUTPUT
Expand All @@ -128,7 +127,7 @@ jobs:
for i in {1..60}; do
build_status=$(curl -s -L \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ secrets.COMMENT_GITHUB_TOKEN }}" \
-H "Authorization: Bearer ${{ secrets.DOCS_GITHUB_PAT }}" \
-H "X-GitHub-Api-Version: 2022-11-28" '${{ steps.ghpages_build.outputs.url }}' \
| jq -r .status)
Expand All @@ -153,7 +152,7 @@ jobs:
if: ${{ steps.fc.outputs.comment-id != '' }}
uses: peter-evans/create-or-update-comment@v3
with:
token: ${{ secrets.COMMENT_GITHUB_TOKEN }}
token: ${{ secrets.DOCS_GITHUB_PAT }}
comment-id: ${{ steps.fc.outputs.comment-id }}
body: |
Deployment successful! [View preview](${{ steps.draft_url.outputs.url }})
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/dispatch-deploy-draft.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ jobs:
with:
owner: riptano
repo: datastax-docs-site
github_token: ${{ secrets.DISPATCH_GITHUB_TOKEN }}
github_user: mlr
github_token: ${{ secrets.DOCS_GITHUB_PAT }}
workflow_file_name: deploy-draft.yml
client_payload: '{ "build_repository": "${{ github.event.repository.full_name }}", "build_branch": "main", "draft_branch": "${{ github.event.pull_request.head.ref }}", "pull_request_number": "${{ github.event.pull_request.number }}", "ui_bundle_repository": "${{ github.event.repository.full_name }}", "ui_bundle_branch": "${{ github.event.pull_request.head.ref }}" }'

0 comments on commit db67713

Please sign in to comment.