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

Enable Declarative Gradle site previews #143

Merged
merged 1 commit into from
Nov 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,17 @@ jobs:
# Build job
build:
runs-on: ubuntu-latest

permissions:
contents: write
packages: read
pull-requests: write

env:
PR_PATH: pull/${{github.event.number}}
DOMAIN: gradle.github.io
PREVIEW_REPO: community-site-preview

steps:
- name: Checkout
uses: actions/checkout@v3
Expand All @@ -25,3 +36,27 @@ jobs:

- name: Build the docs
run: mkdocs build

- name: Deploy to PR preview
uses: peaceiris/actions-gh-pages@v4
if: github.ref != 'refs/heads/main'
with:
deploy_key: ${{ secrets.PREVIEW_DEPLOYMENT_KEY }}
external_repository: gradle/${{ env.PREVIEW_REPO }}
publish_dir: ./_site
destination_dir: ${{ env.PR_PATH }}

- name: Update comment
uses: hasura/[email protected]
if: github.ref != 'refs/heads/main'
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
repository: ${{ github.repository }}
number: ${{ github.event.number }}
id: deploy-preview
message: >
A preview of ${{ github.event.after }} is uploaded and can be seen here:

✨ https://${{ env.DOMAIN }}/${{ env.PREVIEW_REPO }}/${{ env.PR_PATH}}/ ✨

Changes may take a few minutes to propagate.
37 changes: 37 additions & 0 deletions .github/workflows/preview-cleanup.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Delete preview on PR close
on:
pull_request:
types: [closed]

jobs:
delete_preview:
runs-on: ubuntu-20.04
env:
PR_PATH: pull/${{github.event.number}}
DOMAIN: gradle.github.io
PREVIEW_REPO: community-site-preview

permissions:
pull-requests: write

steps:
- name: make empty dir
run: mkdir public

- name: delete folder
uses: peaceiris/actions-gh-pages@v3
with:
deploy_key: ${{ secrets.PREVIEW_DEPLOYMENT_KEY }}
external_repository: gradle/${{ env.PREVIEW_REPO }}
publish_dir: ./public
destination_dir: ${{ env.PR_PATH }}

- name: Comment on PR
uses: hasura/[email protected]
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
repository: ${{ github.repository }}
number: ${{ github.event.number }}
id: deploy-preview
message: >
🪓 PR closed, deleted preview at https://github.com/${{ env.PREVIEW_REPO }}/tree/gh-pages/${{ env.PR_PATH }}/
Loading