Skip to content

Commit 2ec0d8b

Browse files
committed
Use artifact name to determine PR
1 parent 79e9e7f commit 2ec0d8b

File tree

2 files changed

+23
-26
lines changed

2 files changed

+23
-26
lines changed

.github/workflows/build.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ jobs:
3636
MKDOCS_ENABLE_GIT_COMMITTERS: ${{ github.token && 'True' || 'False' }}
3737
run: |
3838
mkdocs build --strict
39-
- name: Upload build pages as artifact
39+
- name: Upload pages as an artifact
4040
uses: actions/upload-artifact@v4
4141
with:
42-
name: page-build
42+
name: ${{ github.event.number || 'main' }}
4343
path: public/

.github/workflows/deploy-prod.yml

Lines changed: 21 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -19,23 +19,23 @@ jobs:
1919
with:
2020
run-id: ${{ github.event.workflow_run.id }}
2121
github-token: ${{ github.token }}
22+
merge-multiple: true
2223
name: page-build
2324
path: public
2425

2526
- name: change URLs for large files
2627
shell: bash
27-
run: |
28-
sed -i 's|search/search_index.json|https://storage.googleapis.com/cp-algorithms/search_index.json|g' public/assets/javascripts/*.js
28+
run: sed -i 's|search/search_index.json|https://storage.googleapis.com/cp-algorithms/search_index.json|g' public/assets/javascripts/*.js
2929

30-
- id: 'auth'
31-
uses: 'google-github-actions/auth@v2.1.6'
30+
- id: auth
31+
uses: google-github-actions/auth@v2.1.6
3232
with:
3333
credentials_json: '${{ secrets.GCP_CREDENTIALS }}'
3434

35-
- uses: 'google-github-actions/upload-cloud-storage@v1'
35+
- uses: google-github-actions/upload-cloud-storage@v1
3636
with:
37-
path: 'public/search/search_index.json'
38-
destination: 'cp-algorithms'
37+
path: public/search/search_index.json
38+
destination: cp-algorithms
3939

4040
- uses: FirebaseExtended/action-hosting-deploy@v0
4141
id: firebase-deploy
@@ -60,33 +60,30 @@ jobs:
6060
name: page-build
6161
path: public
6262

63-
- name: Configure git
63+
- name: Get PR number from artifact
64+
id: get-pr-number
65+
run: echo "pr_number=$(ls public)" >> $GITHUB_OUTPUT
66+
67+
- name: Configure git
6468
run: |
6569
git config --global user.name "github-actions[bot]"
6670
git config --global user.email "github-actions[bot]@users.noreply.github.com"
67-
68-
- name: Get PR information
69-
uses: potiuk/get-workflow-origin@v1_6
70-
id: source-run-info
71-
with:
72-
token: ${{ github.token }}
73-
sourceRunId: ${{ github.event.workflow_run.id }}
74-
71+
7572
- name: Deploy to gh-pages
7673
uses: peaceiris/actions-gh-pages@v3
7774
with:
7875
github_token: ${{ github.token }}
79-
publish_dir: ./public
76+
publish_dir: public/${{ steps.get-pr-number.outputs.pr_number }}
8077
publish_branch: gh-pages
81-
destination_dir: ${{ steps.source-run-info.outputs.pullRequestNumber || 'main' }}/
82-
78+
destination_dir: ${{ steps.get-pr-number.outputs.pr_number }}
79+
80+
8381
- name: Create or update PR comment
84-
if: steps.source-run-info.outputs.pullRequestNumber
82+
if: steps.get-pr-number.outputs.pr_number != 'main'
8583
uses: peter-evans/create-or-update-comment@v3
8684
with:
87-
token: ${{ secrets.GITHUB_TOKEN }}
88-
issue-number: ${{ steps.source-run-info.outputs.pullRequestNumber }}
89-
body: |
90-
Preview the changes for PR #${{ steps.source-run-info.outputs.pullRequestNumber }} (${{ github.event.workflow_run.head_sha }}) here: https://gh.cp-algorithms.com/${{ steps.source-run-info.outputs.pullRequestNumber }}/
85+
token: ${{ github.token }}
86+
issue-number: ${{ steps.get-pr-number.outputs.pr_number }}
87+
body: 'Preview the changes for PR #${{ steps.get-pr-number.outputs.pr_number }} (${{ github.event.workflow_run.head_sha }}) [here](https://gh.cp-algorithms.com/${{ steps.get-pr-number.outputs.pr_number }}/).'
9188
body-includes: 'Preview the changes for PR'
9289
mode: replace

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy