Skip to content

Commit

Permalink
Use managed PAT for bundle preview and release builds [no-release]
Browse files Browse the repository at this point in the history
  • Loading branch information
mlr committed Aug 26, 2024
1 parent ed28d4e commit 18aa581
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
18 changes: 10 additions & 8 deletions .github/workflows/deploy-bundle-preview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- name: Configure Git Credentials
uses: de-vri-es/setup-git-credentials@v2
with:
credentials: ${{ secrets.GIT_CREDENTIALS }}
credentials: https://${{ secrets.DOCS_GITHUB_PAT }}@github.com

- name: Checkout Repository
uses: actions/checkout@v4
Expand Down 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,15 +79,17 @@ 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

- name: Deploy to GitHub Pages
if: success()
run: |
# Configure git to use the PAT for cloning and pushing to the gh-pages branch
git config --global url.https://${{ secrets.DOCS_GITHUB_PAT }}@github.com/.insteadOf https://github.com/
git clone https://github.com/$GITHUB_REPOSITORY.git pages
cd pages
git checkout gh-pages
Expand Down Expand Up @@ -116,7 +118,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 +130,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 +155,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
4 changes: 1 addition & 3 deletions .github/workflows/release-ui-bundle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- name: Configure Git Credentials
uses: de-vri-es/setup-git-credentials@v2
with:
credentials: ${{ secrets.GIT_CREDENTIALS }}
credentials: https://${{ secrets.DOCS_GITHUB_PAT }}@github.com

- name: Checkout Repository
uses: actions/checkout@v4
Expand All @@ -25,8 +25,6 @@ jobs:

- name: Check Last Commit Message
id: skip_release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
last_commit_message=$(git log -1 --pretty=%B)
if [[ $last_commit_message == *"[no-release]"* ]]; then
Expand Down

0 comments on commit 18aa581

Please sign in to comment.