-
Notifications
You must be signed in to change notification settings - Fork 5
115 lines (103 loc) · 3.64 KB
/
preview.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
name: "preview"
on:
workflow_run:
workflows: ["ready_for_review"]
types:
- completed
concurrency:
group: ${{ github.ref }}
cancel-in-progress: true
jobs:
docs:
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'success' }}
steps:
- name: Download workflow artifact
uses: dawidd6/[email protected]
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
workflow: peek_icons.yml
run_id: ${{ github.event.workflow_run.id }}
- name: Read the pr_num file
id: pr_num_reader
uses: juliangruber/[email protected]
with:
path: ./pr_num/pr_num.txt
- name: Checkout
uses: actions/checkout@v4
with:
path: main
- name: Checkout Pull Request
env:
GITHUB_USER: ${{ secrets.GITHUB_USER }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
cd main
gh pr checkout ${{ steps.pr_num_reader.outputs.content }}
cd ..
- uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Install and configure Poetry
uses: snok/install-poetry@v1
- name: Install dependencies and build doc
run: |
set +e
cd main
curl -C - https://raw.githubusercontent.com/rlberry-py/rlberry/main/pyproject.toml > pyproject.toml
poetry install --all-extras --with dev --sync
poetry run sphinx-build docs ../_build
echo "exitcode=$?" >> $GITHUB_ENV
cd ..
- uses: actions/checkout@v4
with:
# This is necessary so that we have the tags.
fetch-depth: 0
ref: gh-pages
path: gh_pages
- name: Commit documentation changes
if: ${{ env.exitcode == 0 }}
run: |
cd gh_pages
rm -r preview_pr || echo "Ignoring exit status"
mkdir preview_pr
cp -rv ../_build/* preview_pr
git config user.name github-actions
git config user.email [email protected]
git add .
git commit -m "Preview documentation"
git push
- name: Comment on the PR about the result
uses: jungwinter/comment@v1 # let us comment on a specific PR
if: ${{ env.exitcode == 0 }}
env:
MESSAGE: |
Hello,
The build of the doc succeeded. The documentation preview is available here:
https://rlberry-py.github.io/rlberry/preview_pr
with:
type: create
issue_number: ${{ steps.pr_num_reader.outputs.content }}
token: ${{ secrets.GITHUB_TOKEN }}
body: >
${{ format(env.MESSAGE,
fromJSON(steps.icons_overview_img_step.outputs.markdown_urls)[0],
join(fromJSON(steps.icons_detailed_img_step.outputs.markdown_urls), '')) }}
- name: Comment on the PR about the result, fail
uses: jungwinter/comment@v1 # let us comment on a specific PR
if: ${{ env.exitcode != 0 }}
env:
MESSAGE: |
Hello,
The build of the doc failed. Look up the reason here:
https://github.com/rlberry-py/rlberry/actions/workflows/preview.yml
with:
type: create
issue_number: ${{ steps.pr_num_reader.outputs.content }}
token: ${{ secrets.GITHUB_TOKEN }}
body: >
${{ format(env.MESSAGE,
fromJSON(steps.icons_overview_img_step.outputs.markdown_urls)[0],
join(fromJSON(steps.icons_detailed_img_step.outputs.markdown_urls), '')) }}
- name: Exit
run: exit "$exitcode"