-
Notifications
You must be signed in to change notification settings - Fork 190
ci: add per-PR website preview workflow #1058
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
Draft
benbellick
wants to merge
6
commits into
main
Choose a base branch
from
ci/pr-preview-workflow
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+92
−0
Draft
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
c65e90b
ci: add per-PR website preview workflow
benbellick c08c557
ci: include workflow file in preview path filter
benbellick 1fbcb6e
ci: shorten site_url rewrite to satisfy yamllint
benbellick f9ad108
ci: shorten preview URL path to /preview/<N>/
benbellick 3ee6a28
ci: use actions/checkout for cleanup ssh setup
benbellick 3c8cf3c
ci: cancel superseded preview runs and drop emoji from comment
benbellick File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,92 @@ | ||
| name: PR Preview | ||
|
|
||
| on: | ||
| pull_request: | ||
| types: [opened, reopened, synchronize, closed] | ||
| paths: | ||
| - "site/**" | ||
| - "extensions/**" | ||
| - "text/**" | ||
| - ".github/workflows/pr-preview.yml" | ||
|
|
||
| concurrency: | ||
| group: preview-${{ github.ref }} | ||
| cancel-in-progress: true | ||
|
|
||
| permissions: | ||
| contents: read | ||
| pull-requests: write | ||
|
|
||
| jobs: | ||
| deploy: | ||
| name: Deploy PR Preview | ||
| runs-on: ubuntu-latest | ||
| if: >- | ||
| github.repository == 'substrait-io/substrait' && | ||
| github.event.pull_request.head.repo.full_name == github.repository && | ||
| github.event.action != 'closed' | ||
| steps: | ||
| - uses: actions/checkout@v6 | ||
| - uses: prefix-dev/setup-pixi@v0.9.5 | ||
| with: | ||
| pixi-version: v0.66.0 | ||
| cache: true | ||
| - name: Copy schema file for website | ||
| run: | | ||
| mkdir -p ./site/docs/schemas | ||
| cp ./text/simple_extensions_schema.yaml ./site/docs/schemas/simple_extensions | ||
| - name: Rewrite site_url for preview | ||
| env: | ||
| PR: ${{ github.event.pull_request.number }} | ||
| run: | | ||
| sed -i "s|^site_url:.*|site_url: \"https://substrait.io/preview/${PR}/\"|" site/mkdocs.yml | ||
| - name: Generate Static Site | ||
| run: pixi run mkdocs build | ||
| - name: Deploy preview | ||
| uses: peaceiris/actions-gh-pages@v4 | ||
| with: | ||
| external_repository: substrait-io/substrait.io | ||
| publish_branch: main | ||
| deploy_key: ${{ secrets.SUBSTRAIT_SITE_DEPLOY_KEY }} | ||
| publish_dir: ./site/site | ||
| destination_dir: preview/${{ github.event.pull_request.number }} | ||
| keep_files: true | ||
| commit_message: "Deploy preview for PR #${{ github.event.pull_request.number }}" | ||
| - name: Comment preview URL on PR | ||
| uses: marocchino/sticky-pull-request-comment@v2 | ||
| with: | ||
| header: pr-preview | ||
| message: | | ||
| Preview: https://substrait.io/preview/${{ github.event.pull_request.number }}/ | ||
| _Updated for ${{ github.event.pull_request.head.sha }}_ | ||
|
|
||
| cleanup: | ||
| name: Cleanup PR Preview | ||
| runs-on: ubuntu-latest | ||
| if: >- | ||
| github.repository == 'substrait-io/substrait' && | ||
| github.event.pull_request.head.repo.full_name == github.repository && | ||
| github.event.action == 'closed' | ||
| steps: | ||
| - uses: actions/checkout@v6 | ||
| with: | ||
| repository: substrait-io/substrait.io | ||
| ssh-key: ${{ secrets.SUBSTRAIT_SITE_DEPLOY_KEY }} | ||
| path: site-repo | ||
| - name: Remove preview directory | ||
| working-directory: site-repo | ||
| env: | ||
| PR: ${{ github.event.pull_request.number }} | ||
| run: | | ||
| if [ -d "preview/$PR" ]; then | ||
| git config user.name "github-actions[bot]" | ||
| git config user.email "41898282+github-actions[bot]@users.noreply.github.com" | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| git rm -rf "preview/$PR" | ||
| git commit -m "Remove preview for PR #$PR" | ||
| git push | ||
| fi | ||
| - name: Delete preview comment | ||
| uses: marocchino/sticky-pull-request-comment@v2 | ||
| with: | ||
| header: pr-preview | ||
| delete: true | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is there so that we could test it on changes to this file.