-
Notifications
You must be signed in to change notification settings - Fork 829
88 lines (78 loc) · 3.03 KB
/
gh_pages_deploy.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
name: Deploy to GitHub Pages
on:
push:
branches:
- 'main'
workflow_dispatch:
concurrency:
group: 'pages'
cancel-in-progress: true
jobs:
build_assets:
runs-on: ubuntu-20.04
outputs:
should_deploy: ${{ steps.check_deploy.outputs.should_deploy }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.ref }}
repository: ${{ github.event.pull_request.head.repo.full_name }}
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 18
- name: Install Node.js dependencies
working-directory: ./selector
shell: bash
run: npm ci
- name: Validate all notebooks metadata
uses: actions/github-script@v7
with:
script: |
const { NotebookMetadataHandler } = await import('${{ github.workspace }}/selector/src/notebook-metadata/notebook-metadata-handler.js');
const [error, metadataMarkdowns] = NotebookMetadataHandler.validateAll();
core.summary.addHeading(`Validated Notebooks (${metadataMarkdowns.length})`, '2');
core.summary.addRaw(metadataMarkdowns.join('\n\n'));
core.summary.write();
if (error) {
core.setFailed(error);
}
- name: Build static for GitHub Pages
working-directory: ./selector
shell: bash
run: npm run build
- name: Check if deploy needed
id: check_deploy
uses: actions/github-script@v7
with:
script: |
const { readFile } = require('fs/promises');
const { checksumFileName } = await import('${{ github.workspace }}/selector/src/shared/build-checksum.js');
const { owner, repo } = context.repo;
const { data: { html_url }} = await github.rest.repos.getPages({ owner, repo });
const deployedChecksum = await fetch(`${html_url}/${checksumFileName}`).then((res) => res.status === 200 ? res.text() : null);
const currentChecksum = await readFile(`${{ github.workspace }}/selector/dist/openvino_notebooks/${checksumFileName}`, { encoding: 'utf8'});
const isManualDeploy = context.eventName === 'workflow_dispatch';
const shouldDeploy = isManualDeploy || currentChecksum !== deployedChecksum;
core.setOutput('should_deploy', shouldDeploy);
- name: Upload pages artifact
if: ${{ steps.check_deploy.outputs.should_deploy == 'true' }}
uses: actions/upload-pages-artifact@v3
with:
path: ./selector/dist/openvino_notebooks
deploy_github_pages:
runs-on: ubuntu-20.04
needs: build_assets
if: ${{ needs.build_assets.outputs.should_deploy == 'true' }}
permissions:
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4