-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[skip ci] ci: Add workflow to serve documentation preview in PRs from…
… fork
- Loading branch information
1 parent
469d1e5
commit ab20a4a
Showing
1 changed file
with
71 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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,71 @@ | ||
name: serve documentation preview in PR | ||
|
||
on: | ||
workflow_run: | ||
workflows: [sphinx] | ||
types: [completed] | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref }} | ||
cancel-in-progress: true | ||
|
||
permissions: {} | ||
|
||
jobs: | ||
acquire-pr-context: | ||
if: ${{ github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.conclusion == 'success' }} | ||
runs-on: ubuntu-latest | ||
outputs: | ||
PR_NUMBER: ${{ steps.acquire-pr-context.outputs.number }} | ||
PR_HEADSHA: ${{ steps.acquire-pr-context.outputs.headsha }} | ||
permissions: | ||
contents: read | ||
steps: | ||
- id: acquire-pr-context | ||
run: gh pr view --repo "${REPOSITORY}" "${BRANCH}" --json 'number,headRefOid' --jq '"number=\(.number)\nheadsha=\(.headRefOid)"' >> "${GITHUB_OUTPUT}" | ||
env: | ||
GH_TOKEN: ${{ github.token }} | ||
REPOSITORY: ${{ github.repository }} | ||
BRANCH: |- | ||
${{ | ||
(github.event.workflow_run.head_repository.fork == true) | ||
&& format('{0}:{1}', github.event.workflow_run.head_repository.owner.login, github.event.workflow_run.head_branch) | ||
|| github.event.workflow_run.head_branch | ||
}} | ||
serve-documentation-preview: | ||
if: ${{ github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.conclusion == 'success' }} | ||
runs-on: ubuntu-latest | ||
needs: [acquire-pr-context] | ||
permissions: | ||
actions: read | ||
contents: read | ||
pull-requests: write | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Download HTML artifacts | ||
uses: actions/download-artifact@v4 | ||
with: | ||
name: sphinx-html-artifact | ||
path: html/ | ||
github-token: ${{ github.token }} | ||
run-id: ${{ github.event.workflow_run.id }} | ||
|
||
- name: Serve documentation preview | ||
uses: ./.github/actions/sphinx/deploy | ||
with: | ||
CONFIGURATION: ${{ secrets.RCLONE_CONFIG_DOC_PREVIEW }} | ||
BUCKET: ${{ vars.DOCUMENTATION_PREVIEW_BUCKET }} | ||
SOURCE: html/ | ||
DESTINATION: ${{ needs.acquire-pr-context.outputs.PR_NUMBER }}/ | ||
|
||
- name: Comment with documentation preview link | ||
uses: marocchino/sticky-pull-request-comment@v2 | ||
with: | ||
number: ${{ needs.acquire-pr-context.outputs.PR_NUMBER }} | ||
header: documentation-preview | ||
message: >- | ||
[Documentation preview](${{ vars.DOCUMENTATION_PREVIEW_URL }}/${{ needs.acquire-pr-context.outputs.PR_NUMBER }}) | ||
@ ${{ needs.acquire-pr-context.outputs.PR_HEADSHA }} |