Skip to content

Commit ae040fa

Browse files
committed
Update deploy action, setup surge.sh for previews
1 parent ac1839d commit ae040fa

File tree

5 files changed

+148
-65
lines changed

5 files changed

+148
-65
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: Build PR Preview
2+
3+
on:
4+
pull_request:
5+
6+
jobs:
7+
build-website:
8+
name: Build Website
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v4
12+
13+
- name: Generate blog
14+
uses: quarkiverse/quarkus-roq@v1
15+
with:
16+
maven-executable: 'mvn'
17+
maven-build-args: '-DskipTests -Dquarkus.profile=gh-pages'
18+
github-pages: 'false'
19+
setup-java: 'false'
20+
21+
- name: Publishing blog
22+
uses: actions/upload-artifact@v4
23+
with:
24+
name: blog
25+
path: ./target/roq
26+
retention-days: 3

.github/workflows/deploy.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
## Deploy to GH-Pages for your Quarkus Roq blog.
2+
name: Quarkus Roq Deploy CI
3+
4+
on:
5+
push:
6+
branches: [ main ]
7+
workflow_dispatch:
8+
9+
concurrency:
10+
group: ${{ github.workflow }}-${{ github.ref }}
11+
cancel-in-progress: true
12+
13+
jobs:
14+
build:
15+
runs-on: ubuntu-latest
16+
# permissions:
17+
# pages: write # to deploy to Pages
18+
# id-token: write # to verify the deployment originates from an appropriate source
19+
steps:
20+
- uses: actions/checkout@v4
21+
- name: Generate Blog
22+
uses: quarkiverse/quarkus-roq@v1
23+
with:
24+
github-token: ${{ secrets.GITHUB_TOKEN }}
25+
maven-executable: 'mvn'
26+
maven-build-args: '-DskipTests -Dquarkus.profile=gh-pages'
27+
28+
# Deployment job
29+
deploy:
30+
environment:
31+
name: github-pages
32+
url: ${{ steps.deployment.outputs.page_url }}
33+
permissions:
34+
pages: write # to deploy to Pages
35+
id-token: write # to verify the deployment originates from an appropriate source
36+
runs-on: ubuntu-latest
37+
needs: build
38+
steps:
39+
- name: Deploy to GitHub Pages
40+
id: deployment
41+
uses: actions/deploy-pages@v4

.github/workflows/static.yml

Lines changed: 0 additions & 65 deletions
This file was deleted.
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: Surge.sh 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: Dump GitHub context
21+
env:
22+
GITHUB_CONTEXT: ${{ toJson(github) }}
23+
run: echo "$GITHUB_CONTEXT"
24+
25+
- name: Download blog artifact
26+
uses: actions/download-artifact@v4
27+
with:
28+
name: blog
29+
github-token: ${{ secrets.GITHUB_TOKEN }}
30+
run-id: ${{ github.event.workflow_run.id }}
31+
32+
- name: Publishing blog to gh-pages
33+
id: deploy-blog
34+
run: npx surge ./ --domain https://netobserv-io-blog-${{ github.event.workflow_run.pull_requests[0].number }}-preview.surge.sh --token ${{ secrets.SURGE_TOKEN }}
35+
36+
- name: Update PR status comment on success
37+
uses: quarkusio/action-helpers@main
38+
with:
39+
action: maintain-one-comment
40+
github-token: ${{ secrets.GITHUB_TOKEN }}
41+
pr-number: ${{ github.event.workflow_run.pull_requests[0].number }}
42+
body: |
43+
🚀 PR Preview for **blog** ${{ github.sha }} has been successfully built!
44+
* https://netobserv-io-blog-${{ github.event.workflow_run.pull_requests[0].number }}-preview.surge.sh
45+
body-marker: <!-- Preview status comment marker -->
46+
47+
- name: Update PR status comment on failure
48+
uses: quarkusio/action-helpers@main
49+
if: ${{ failure() }}
50+
with:
51+
action: maintain-one-comment
52+
github-token: ${{ secrets.GITHUB_TOKEN }}
53+
pr-number: ${{ github.event.workflow_run.pull_requests[0].number }}
54+
body: |
55+
😭 Deploy PR Preview failed.
56+
body-marker: <!-- Preview status comment marker -->
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-${{ github.event.number }}-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 -->

0 commit comments

Comments
 (0)