Skip to content

Commit 1e7435a

Browse files
committed
setup surge.sh
1 parent d899e19 commit 1e7435a

File tree

2 files changed

+82
-0
lines changed

2 files changed

+82
-0
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: Surge.sh Teardown
2+
3+
on:
4+
pull_request_target:
5+
# when using teardown: 'true', add default event types + closed event type
6+
types: [closed]
7+
8+
jobs:
9+
preview:
10+
runs-on: ubuntu-latest
11+
permissions:
12+
pull-requests: write # Required to update PR status comment
13+
steps:
14+
- name: Teardown Surge.sh preview (blog)
15+
id: teardown-blog
16+
run: npx surge teardown https://netobserv-io-blog-${{ steps.pr.outputs.id }}-preview.surge.sh --token ${{ secrets.SURGE_TOKEN }} || true
17+
- name: Update PR status comment
18+
uses: quarkusio/action-helpers@main
19+
with:
20+
action: maintain-one-comment
21+
github-token: ${{ secrets.GITHUB_TOKEN }}
22+
pr-number: ${{ github.event.number }}
23+
body: |
24+
🙈 The PR is closed and the preview is expired.
25+
body-marker: <!-- Preview status comment marker -->

.github/workflows/preview-pr.yml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: PR Preview
2+
3+
on:
4+
workflow_run:
5+
workflows: [ "Build PR Preview" ]
6+
types:
7+
- completed
8+
9+
defaults:
10+
run:
11+
shell: bash
12+
13+
jobs:
14+
preview:
15+
runs-on: ubuntu-latest
16+
if: github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.conclusion == 'success'
17+
permissions:
18+
pull-requests: write # Required to update PR status comment
19+
steps:
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+
26+
- name: Download blog artifact
27+
uses: actions/download-artifact@v4
28+
with:
29+
name: blog
30+
github-token: ${{ secrets.GITHUB_TOKEN }}
31+
run-id: ${{ github.event.workflow_run.id }}
32+
33+
- name: Publishing blog to gh-pages
34+
id: deploy-blog
35+
run: npx surge ./ --domain https://netobserv-io-blog-${{ steps.pr.outputs.id }}-preview.surge.sh --token ${{ secrets.SURGE_TOKEN }}
36+
37+
- name: Update PR status comment on success
38+
uses: quarkusio/action-helpers@main
39+
with:
40+
action: maintain-one-comment
41+
github-token: ${{ secrets.GITHUB_TOKEN }}
42+
pr-number: ${{ steps.pr.outputs.id }}
43+
body: |
44+
🚀 PR Preview for **blog** ${{ github.sha }} has been successfully built!
45+
* https://netobserv-io-blog-${{ steps.pr.outputs.id }}-preview.surge.sh
46+
body-marker: <!-- Preview status comment marker -->
47+
48+
- name: Update PR status comment on failure
49+
uses: quarkusio/action-helpers@main
50+
if: ${{ failure() }}
51+
with:
52+
action: maintain-one-comment
53+
github-token: ${{ secrets.GITHUB_TOKEN }}
54+
pr-number: ${{ steps.pr.outputs.id }}
55+
body: |
56+
😭 Deploy PR Preview failed.
57+
body-marker: <!-- Preview status comment marker -->

0 commit comments

Comments
 (0)