Skip to content

Commit 807f27f

Browse files
committed
Add workflow for surge preview
Sadly, by definition, this cannot be tested from the pull request, so I will have to push and hope.
1 parent e94b598 commit 807f27f

File tree

2 files changed

+54
-1
lines changed

2 files changed

+54
-1
lines changed

.github/workflows/build_and_publish.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,12 @@ jobs:
3737
- run: npm run test:int
3838
env:
3939
CI: true
40-
40+
- name: Publishing directory for PR preview
41+
uses: actions/upload-artifact@v2
42+
with:
43+
name: site
44+
path: ./public
45+
retention-days: 3
4146
deploy:
4247
# Only try and deploy on merged code
4348
if: "github.repository == 'quarkusio/extensions' && github.ref_name == 'main' && (github.event_name == 'push' || github.event_name == 'schedule')"

.github/workflows/preview.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: Surge PR Preview
2+
3+
on:
4+
workflow_run:
5+
workflows: [ "Gatsby Publish" ]
6+
types:
7+
- completed
8+
9+
jobs:
10+
preview:
11+
runs-on: ubuntu-20.04
12+
if: github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.conclusion == 'success'
13+
steps:
14+
- name: Download PR Artifact
15+
uses: dawidd6/action-download-artifact@v2
16+
with:
17+
workflow: ${{ github.event.workflow_run.workflow_id }}
18+
workflow_conclusion: success
19+
name: site
20+
- name: Store PR id as variable
21+
id: pr
22+
run: |
23+
echo "id=$(<pr-id.txt)" >> $GITHUB_OUTPUT
24+
rm -f pr-id.txt
25+
- name: Publishing to surge for preview
26+
id: deploy
27+
run: npx surge ./ --domain https://extensions-quarkus-io-pr-${{ steps.pr.outputs.id }}-preview.surge.sh --token ${{ secrets.SURGE_TOKEN }}
28+
- name: Update PR status comment on success
29+
uses: actions-cool/[email protected]
30+
with:
31+
token: ${{ secrets.GITHUB_TOKEN }}
32+
body: |
33+
🚀 PR Preview ${{ github.sha }} has been successfully built and deployed to https://quarkus-io-pr-${{ steps.pr.outputs.id }}-preview.surge.sh
34+
<img width="300" src="https://user-images.githubusercontent.com/507615/90250366-88233900-de6e-11ea-95a5-84f0762ffd39.png">
35+
<!-- Sticky Pull Request Comment -->
36+
body-include: '<!-- Sticky Pull Request Comment -->'
37+
number: ${{ steps.pr.outputs.id }}
38+
- name: Update PR status comment on failure
39+
if: ${{ failure() }}
40+
uses: actions-cool/[email protected]
41+
with:
42+
token: ${{ secrets.GITHUB_TOKEN }}
43+
body: |
44+
😭 Deploy PR Preview failed.
45+
<img width="300" src="https://user-images.githubusercontent.com/507615/90250824-4e066700-de6f-11ea-8230-600ecc3d6a6b.png">
46+
<!-- Sticky Pull Request Comment -->
47+
body-include: '<!-- Sticky Pull Request Comment -->'
48+
number: ${{ steps.pr.outputs.id }}

0 commit comments

Comments
 (0)