Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Actions to preview docs #511

Merged
merged 12 commits into from
Oct 23, 2023
21 changes: 21 additions & 0 deletions .github/workflows/build-adoc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Build Adoc

on:
pull_request:
paths:
- '*.adoc'

jobs:
pre-preview:
name: ADOC - Workflow
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest]
java: [
{ 'version': '11' },
{ 'version': '17' }
]
steps:
- name: Pre preview
run: echo Pre preview
ricardozanini marked this conversation as resolved.
Show resolved Hide resolved
48 changes: 48 additions & 0 deletions .github/workflows/preview.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Surge.sh Preview

on:
workflow_run:
workflows: ["Build Adoc"]
types:
- completed

jobs:
preview:
runs-on: ubuntu-latest
if: github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.conclusion == 'success'
steps:
- name: Download PR Artifact
uses: dawidd6/action-download-artifact@v2
with:
workflow: ${{ github.event.workflow_run.workflow_id }}
workflow_conclusion: success
name: site
- name: Store PR id as variable
id: pr
run: |
echo "id=$(<pr-id.txt)" >> $GITHUB_OUTPUT
luanbrdev marked this conversation as resolved.
Show resolved Hide resolved
rm -f pr-id.txt
- name: Publishing to surge for preview
id: deploy
run: npx surge ./ --domain https://quarkus-website-pr-${{ steps.pr.outputs.id }}-preview.surge.sh --token ${{ secrets.SURGE_TOKEN }}
luanbrdev marked this conversation as resolved.
Show resolved Hide resolved
- name: Update PR status comment on success
uses: actions-cool/maintain-one-comment@v3.0.0
luanbrdev marked this conversation as resolved.
Show resolved Hide resolved
with:
token: ${{ secrets.GITHUB_TOKEN }}
body: |
🎊 PR Preview ${{ github.sha }} has been successfully built and deployed to https://quarkus-website-pr-${{ steps.pr.outputs.id }}-preview.surge.sh
<img width="300" src="https://user-images.githubusercontent.com/507615/90250366-88233900-de6e-11ea-95a5-84f0762ffd39.png">
<!-- Sticky Pull Request Comment -->
body-include: '<!-- Sticky Pull Request Comment -->'
number: ${{ steps.pr.outputs.id }}
- name: Update PR status comment on failure
if: ${{ failure() }}
uses: actions-cool/maintain-one-comment@v3.0.0
luanbrdev marked this conversation as resolved.
Show resolved Hide resolved
with:
token: ${{ secrets.GITHUB_TOKEN }}
body: |
😭 Deploy PR Preview failed.
<img width="300" src="https://user-images.githubusercontent.com/507615/90250824-4e066700-de6f-11ea-8230-600ecc3d6a6b.png">
<!-- Sticky Pull Request Comment -->
body-include: '<!-- Sticky Pull Request Comment -->'
number: ${{ steps.pr.outputs.id }}
24 changes: 24 additions & 0 deletions .github/workflows/preview_teardown.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Surge.sh Preview Teardown

on:
pull_request_target:
paths:
- '*.adoc'
types: [closed]

jobs:
preview-teardown:
runs-on: ubuntu-latest
steps:
- name: Teardown surge preview
id: deploy
run: npx surge teardown https://quarkus-website-pr-${{ github.event.number }}-preview.surge.sh --token ${{ secrets.SURGE_TOKEN }}
- name: Update PR status comment
uses: actions-cool/maintain-one-comment@v3.0.0
luanbrdev marked this conversation as resolved.
Show resolved Hide resolved
with:
token: ${{ secrets.GITHUB_TOKEN }}
body: |
🙈 The PR is closed and the preview is expired.
<!-- Sticky Pull Request Comment -->
body-include: '<!-- Sticky Pull Request Comment -->'
number: ${{ github.event.number }}