This repository has been archived by the owner on Nov 22, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 35
61 lines (56 loc) · 2.13 KB
/
deploy-pr-docs.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
name: Deploy PR docs to GitHub Pages
on:
workflow_run:
workflows:
- 'Build docs from a pull request'
types:
- completed
jobs:
deploy-built-docs:
name: Deploy built docs to GitHub Pages
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'success' }}
steps:
- name: Download the docs artifact 📥
uses: dawidd6/action-download-artifact@a430ac5786b39ad5869da25a98130624d2ce340c
with:
workflow: build-pr-docs.yml
commit: ${{ github.event.workflow_run.head_sha }}
name: docs
path: ./docs
- name: Download the PR number artifact 📥
uses: dawidd6/action-download-artifact@a430ac5786b39ad5869da25a98130624d2ce340c
with:
workflow: build-pr-docs.yml
name: pr_number
- name: Add PR number to environment 🌎
run: echo "PR_NUMBER=$(cat pr_number.txt)" >> $GITHUB_ENV
- name: Publish 🚀
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: docs
destination_dir: ${{ env.PR_NUMBER }}
keep_files: true
- name: Post the URL on the PR 🖊
uses: actions/github-script@v7
with:
script:
| # yeah, I know it's weird how you get PR comments with `.issues`
const prComments = (await github.issues.listComments({
issue_number: ${{ env.PR_NUMBER }},
owner: context.repo.owner,
repo: context.repo.repo,
})).data;
const docsURL = /Docs available on https:\/\/illright\.github\.io\/attractions\/\d+\//;
if (prComments.find(
comment => comment.user.login === 'github-actions[bot]' && docsURL.test(comment.body)
) != null) {
return;
}
await github.issues.createComment({
issue_number: ${{ env.PR_NUMBER }},
owner: context.repo.owner,
repo: context.repo.repo,
body: 'Docs available on https://illright.github.io/attractions/${{ env.PR_NUMBER }}/'
});