Deploy Documentation Preview #32
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
name: Deploy Documentation Preview | |
on: | |
workflow_run: | |
workflows: [Tests And Linting] | |
types: [completed] | |
jobs: | |
deploy: | |
if: ${{ github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.event == 'pull_request' }} | |
runs-on: ubuntu-latest | |
permissions: | |
issues: write | |
pull-requests: write | |
steps: | |
- name: Check out repository | |
uses: actions/checkout@v4 | |
- name: Download artifact | |
uses: dawidd6/action-download-artifact@v2 | |
with: | |
workflow_conclusion: success | |
run_id: ${{ github.event.workflow_run.id }} | |
path: docs-preview | |
name: docs-preview | |
- name: Set PR number | |
run: echo "PR_NUMBER=$(cat docs-preview/.pr_number)" >> $GITHUB_ENV | |
- name: Deploy docs preview | |
uses: JamesIves/github-pages-deploy-action@v4 | |
with: | |
folder: docs-preview/docs/_build/html | |
ssh-key: ${{ secrets.DOCS_PREVIEW_DEPLOY_KEY }} | |
repository-name: jolt-org/type-lens-docs-preview | |
clean: false | |
target-folder: ${{ env.PR_NUMBER }} | |
branch: gh-pages | |
- uses: actions/github-script@v6 | |
env: | |
PR_NUMBER: ${{ env.PR_NUMBER }} | |
with: | |
script: | | |
const issue_number = process.env.PR_NUMBER | |
const body = "Documentation preview will be available shortly at https://jolt-org.github.io/type-lens-docs-preview/" + issue_number | |
const opts = github.rest.issues.listComments.endpoint.merge({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
issue_number: issue_number, | |
}); | |
const comments = await github.paginate(opts) | |
for (const comment of comments) { | |
if (comment.user.id === 41898282 && comment.body === body) { | |
await github.rest.issues.deleteComment({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
comment_id: comment.id | |
}) | |
} | |
} | |
await github.rest.issues.createComment({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
issue_number: issue_number, | |
body: body, | |
}) |