-
Notifications
You must be signed in to change notification settings - Fork 90
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add custom preview deploy/undeploy steps
- Loading branch information
Showing
2 changed files
with
40 additions
and
16 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
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 |
---|---|---|
|
@@ -126,40 +126,63 @@ jobs: | |
mkdir -p artifacts/docs | ||
mv cuda_python/docs/build/html/* artifacts/docs/ | ||
# create an empty folder for removal use | ||
mkdir -p artifacts/empty_docs | ||
# TODO: remove this step | ||
- name: Upload doc artifacts | ||
uses: actions/upload-pages-artifact@v3 | ||
with: | ||
path: artifacts/ | ||
retention-days: 3 | ||
|
||
- name: Collect PR data | ||
uses: actions/github-script@v7 | ||
id: get_pr_data | ||
with: | ||
script: | | ||
return ( | ||
await github.rest.repos.listPullRequestsAssociatedWithCommit({ | ||
commit_sha: context.sha, | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
}) | ||
).data[0]; | ||
- name: Get PR number | ||
run: | | ||
PR_NUMBER="${{ fromJson(steps.get_pr_data.outputs.result).number }}" | ||
echo "PR_NUMBER=${PR_NUMBER}" >> $GITHUB_ENV | ||
# Note: the PR previews will be removed once merged to main (see below) | ||
- uses: rossjrw/pr-preview-action@v1 | ||
if: ${{ github.ref_name != 'main' && success() }} | ||
- name: Deploy doc preview | ||
if: ${{ github.ref_name != 'main' }} | ||
uses: JamesIves/github-pages-deploy-action@v4 | ||
with: | ||
source-dir: artifacts/docs/ | ||
preview-branch: gh-pages | ||
umbrella-dir: docs/pr-preview | ||
pages-base-path: docs | ||
action: deploy | ||
git-config-name: cuda-python-bot | ||
git-config-email: [email protected] | ||
folder: artifacts/docs/ | ||
target-folder: docs/pr-preview/pr-${{ env.PR_NUMBER }}/ | ||
commit-message: "Deploy doc preview for PR ${{ env.PR_NUMBER }} (${{ github.sha }})" | ||
|
||
# The steps below are not executed unless when building on main. | ||
- name: Deploy doc update | ||
if: ${{ github.ref_name == 'main' && success() }} | ||
if: ${{ github.ref_name == 'main' }} | ||
uses: JamesIves/github-pages-deploy-action@v4 | ||
with: | ||
folder: artifacts/docs/ | ||
git-config-name: cuda-python-bot | ||
git-config-email: [email protected] | ||
folder: artifacts/docs/ | ||
target-folder: docs/ | ||
commit-message: "Deploy latest docs: ${{ github.sha }}" | ||
clean: false | ||
|
||
- uses: rossjrw/pr-preview-action@v1 | ||
if: ${{ github.ref_name == 'main' && success() }} | ||
- name: Remove doc preview | ||
if: ${{ github.ref_name == 'main' }} | ||
uses: JamesIves/github-pages-deploy-action@v4 | ||
with: | ||
source-dir: artifacts/docs/ | ||
preview-branch: gh-pages | ||
umbrella-dir: docs/pr-preview | ||
pages-base-path: docs | ||
action: remove | ||
git-config-name: cuda-python-bot | ||
git-config-email: [email protected] | ||
folder: artifacts/empty_docs/ | ||
target-folder: docs/pr-preview/pr-${{ env.PR_NUMBER }}/ | ||
commit-message: "Deploy doc preview for PR ${{ env.PR_NUMBER }} (${{ github.sha }})" |