-
Notifications
You must be signed in to change notification settings - Fork 16
47 lines (39 loc) · 1.65 KB
/
deploy-data.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
name: Validate/Deploy Data
on:
push: { branches: [master] }
jobs:
validate-then-deploy:
name: Validate, then deploy data
runs-on: ubuntu-latest
steps:
- name: Check out the code
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4
with: {node-version-file: '.node-version'}
- name: Install dependencies
run: npm ci
- name: Validate the data
run: |
npm run validate-bus-data
npm run validate-data
# Having validated the data, we now prepare a bundle. This script creates
# files in a docs/ directory.
- name: Bundle the data
run: npm run bundle-data
# Notes: actions/checkout@v2 no longer fetches entire history nor enters
# detached HEAD state. We really just need to check out an (orphaned)
# branch and then add, commit, and push the appropriate directory.
- name: Commit the data
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
git checkout --orphan "gh-pages-$GITHUB_SHA"
git --work-tree=docs add .
git commit -m "Automated data deployment at $(date -Is)"
git show --stat HEAD
# If the previous commit successfully happened, download the latest state
# of the remote branch gh-pages.
- name: Deploy the data
run: |
git fetch --prune --unshallow origin gh-pages
git push --force-with-lease origin "gh-pages-$GITHUB_SHA:gh-pages"