Skip to content

Commit 901043e

Browse files
committed
ci: Add workflow to serve documentation preview in PRs
1 parent 056ae94 commit 901043e

File tree

4 files changed

+44
-10
lines changed

4 files changed

+44
-10
lines changed

.github/actions/sphinx/deploy/action.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ inputs:
1414
required: false
1515
default: scaleway
1616
BUCKET:
17-
required: false
18-
default: prod-probabl-skore
17+
required: true
1918
SOURCE:
2019
required: true
2120
DESTINATION:

.github/workflows/pr-display-backend-coverage.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ permissions: {}
1313

1414
jobs:
1515
acquire-pr-number:
16-
if: github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.conclusion == 'success'
16+
if: ${{ github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.conclusion == 'success' }}
1717
runs-on: ubuntu-latest
1818
outputs:
1919
PR_NUMBER: ${{ steps.acquire-pr-number.outputs.number }}
@@ -33,7 +33,7 @@ jobs:
3333
}}
3434
3535
display-backend-coverage:
36-
if: github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.conclusion == 'success'
36+
if: ${{ github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.conclusion == 'success' }}
3737
runs-on: ubuntu-latest
3838
needs: [acquire-pr-number]
3939
permissions:

.github/workflows/pr-display-frontend-coverage.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ permissions: {}
1313

1414
jobs:
1515
acquire-pr-number:
16-
if: github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.conclusion == 'success'
16+
if: ${{ github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.conclusion == 'success' }}
1717
runs-on: ubuntu-latest
1818
outputs:
1919
PR_NUMBER: ${{ steps.acquire-pr-number.outputs.number }}
@@ -33,7 +33,7 @@ jobs:
3333
}}
3434
3535
display-frontend-coverage:
36-
if: github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.conclusion == 'success'
36+
if: ${{ github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.conclusion == 'success' }}
3737
runs-on: ubuntu-latest
3838
needs: [acquire-pr-number]
3939
permissions:

.github/workflows/sphinx.yml

Lines changed: 39 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,41 @@ jobs:
115115
name: sphinx-html-artifact
116116
path: sphinx/build/html/
117117

118-
sphinx-deploy-html:
118+
sphinx-preview:
119+
if: ${{ github.event_name == 'pull_request' }}
119120
runs-on: ubuntu-latest
121+
needs: sphinx-build
122+
permissions:
123+
actions: read
124+
contents: read
125+
pull-requests: write
126+
steps:
127+
- uses: actions/checkout@v4
128+
129+
- uses: actions/download-artifact@v4
130+
with:
131+
name: sphinx-html-artifact
132+
path: html/
133+
134+
- uses: ./.github/actions/sphinx/deploy
135+
with:
136+
CONFIGURATION: ${{ secrets.RCLONE_CONFIG_DOC_PREVIEW }}
137+
BUCKET: ${{ vars.DOCUMENTATION_PREVIEW_BUCKET }}
138+
SOURCE: html/
139+
DESTINATION: ${{ github.event.number }}/
140+
141+
- uses: marocchino/sticky-pull-request-comment@v2
142+
with:
143+
number: ${{ github.event.number }}
144+
header: documentation-preview
145+
recreate: true
146+
message: >-
147+
[Documentation preview](${{ vars.DOCUMENTATION_PREVIEW_URL }}/${{ github.event.number }})
148+
@ commit: ${{ github.event.pull_request.head.sha }}
149+
150+
sphinx-deploy-html:
120151
if: ${{ (github.event_name == 'release') || (github.event_name == 'push' && github.ref == 'refs/heads/main') }}
152+
runs-on: ubuntu-latest
121153
needs: [sphinx-version, sphinx-build]
122154
steps:
123155
- uses: actions/checkout@v4
@@ -128,12 +160,13 @@ jobs:
128160
- uses: ./.github/actions/sphinx/deploy
129161
with:
130162
CONFIGURATION: ${{ secrets.RCLONE_CONFIG_DOCS }}
163+
BUCKET: ${{ vars.DOCUMENTATION_BUCKET }}
131164
SOURCE: html/
132165
DESTINATION: ${{ needs.sphinx-version.outputs.SPHINX_VERSION }}/
133166

134167
sphinx-deploy-root-files:
135-
runs-on: ubuntu-latest
136168
if: ${{ github.event_name == 'release' }}
169+
runs-on: ubuntu-latest
137170
needs: [sphinx-version, sphinx-build, sphinx-deploy-html]
138171
steps:
139172
- uses: actions/checkout@v4
@@ -144,7 +177,7 @@ jobs:
144177
import operator
145178
import json
146179
147-
url = "https://skore.probabl.ai"
180+
url = os.environ["URL"]
148181
current = os.environ["CURRENT"]
149182
150183
response = requests.get(f"{url}/versions.json")
@@ -177,18 +210,20 @@ jobs:
177210
"""
178211
)
179212
env:
213+
URL: ${{ vars.DOCUMENTATION_URL }}
180214
CURRENT: ${{ needs.sphinx-version.outputs.SPHINX_VERSION }}
181215
- uses: ./.github/actions/sphinx/deploy
182216
with:
183217
CONFIGURATION: ${{ secrets.RCLONE_CONFIG_DOCS }}
218+
BUCKET: ${{ vars.DOCUMENTATION_BUCKET }}
184219
ACTION: copy
185220
SOURCE: artifacts/
186221
DESTINATION:
187222

188223
sphinx-clean:
189224
runs-on: ubuntu-latest
190225
if: always()
191-
needs: [sphinx-version, sphinx-build, sphinx-deploy-html, sphinx-deploy-root-files]
226+
needs: [sphinx-version, sphinx-build, sphinx-preview, sphinx-deploy-html, sphinx-deploy-root-files]
192227
steps:
193228
- uses: geekyeggo/delete-artifact@v5
194229
with:

0 commit comments

Comments
 (0)