-
Notifications
You must be signed in to change notification settings - Fork 521
63 lines (57 loc) · 2.57 KB
/
jupyter-book-pr-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
name: jupyter-book-pr-preview
on:
workflow_run:
workflows: ["deploy-gh-pages"]
types:
- completed
jobs:
deploy-preview:
runs-on: ubuntu-latest
if: ${{github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.conclusion == 'success'}}
steps:
- name: 'Commit Status: Set Workflow Status as Pending'
uses: myrotvorets/[email protected]
with:
token: ${{ secrets.GITHUB_TOKEN }}
status: pending
sha: ${{ github.event.workflow_run.head_sha }}
context: 'JupyterBook preview'
- uses: dawidd6/action-download-artifact@v2
with:
github_token: ${{secrets.GITHUB_TOKEN}}
workflow: deploy-gh-pages.yml
run_id: ${{ github.event.workflow_run.id }}
name: jupyter-book
- name: Get pull request number
id: pull-request-number
run: |
export PULL_REQUEST_NUMBER=`cat pull_request_number`
echo "PULL_REQUEST_NUMBER=$PULL_REQUEST_NUMBER"
echo "result=${PULL_REQUEST_NUMBER}" >> $GITHUB_OUTPUT
- uses: actions/setup-node@v3
with:
node-version: '16'
- run: npm install --global netlify-cli@6
- name: Deploy to Netlify
env:
NETLIFY_AUTH_TOKEN: ${{secrets.NETLIFY_AUTH_TOKEN}}
NETLIFY_SITE_ID: ${{secrets.NETLIFY_SITE_ID}}
run: |
echo "Deploying PR ${{steps.pull-request-number.outputs.result}} to Netlify"
netlify deploy --dir=jupyter-book/_build/html --alias=pull-request-${{steps.pull-request-number.outputs.result}}
- name: 'Commit Status: Update deployment status'
uses: myrotvorets/[email protected]
# Always run this step regardless of job failing early
if: always()
env:
DEPLOY_SUCCESS: Successfully deployed preview.
DEPLOY_FAILURE: Failed to deploy preview.
TARGET_URL_SUCCESS: https://pull-request-${{steps.pull-request-number.outputs.result}}--scikit-learn-mooc.netlify.app/_changed.html
TARGET_URL_FAILURE: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
with:
token: ${{ secrets.GITHUB_TOKEN }}
status: ${{ job.status == 'success' && 'success' || 'failure' }}
sha: ${{ github.event.workflow_run.head_sha }}
context: 'JupyterBook preview'
description: ${{ job.status == 'success' && env.DEPLOY_SUCCESS || env.DEPLOY_FAILURE }}
targetUrl: ${{ job.status == 'success' && env.TARGET_URL_SUCCESS || env.TARGET_URL_FAILURE }}