-
Notifications
You must be signed in to change notification settings - Fork 159
128 lines (113 loc) · 4.63 KB
/
site.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
116
117
118
119
120
121
122
123
124
125
126
127
128
name: Docs and Site
on:
push:
paths:
- "docs/**"
branches:
- main
# allows the workflow to be manually executed any time
workflow_dispatch:
permissions:
pages: write
contents: write
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18.x]
steps:
- name: Grab the main Branch
uses: actions/checkout@v2.3.3
with:
path: fhir
ref: refs/heads/main
fetch-depth: 1
token: ${{ secrets.GITHUB_TOKEN }}
- name: Grab the GH Pages Branch
uses: actions/checkout@v2.3.3
with:
path: gh-pages
ref: refs/heads/gh-pages
fetch-depth: 1
token: ${{ secrets.GITHUB_TOKEN }}
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1.4.4
with:
node-version: ${{ matrix.node-version }}
- name: Build Site
run: |
echo "The current path is - $(pwd)"
ls -la
# Checks if the FHIR repo's gh-pages branch is checked out to fhir.
if [ ! -d gh-pages ]
then
echo "Branch not checked out to the correct folder - gh-ages"
exit -2
fi
# Checks if the FHIR repo's main branch is checked out to fhir.
if [ ! -d fhir ]
then
echo "Branch not checked out to the correct folder - FHIR"
exit -3
fi
# Record the currect directory
pushd $(pwd)
cd fhir/docs/
npm install yarn -g
yarn global add gatsby-cli
gatsby telemetry --disable
# Install the packages
# fsevents is not used on linux images, so use --no-optional (these plugins are suspect)
# npm install --no-optional --save react react-copy-to-clipboard react-dom react-ga classnames carbon @carbon/addons-website carbon-components carbon-components-react carbon-addons-cloud carbon-icons gatsby gatsby-theme-carbon-starter markdown-it gatsby-plugin-manifest gatsby-plugin-slug gatsby-plugin-sitemap gatsby-plugin-sharp
# npm install --save gatsby-transformer-remark gatsby-source-filesystem
yarn install
# don't use gatsby build directly per https://github.com/gatsbyjs/gatsby/issues/17557
# use the suggestion as a workaround due to path/issues in the gatsby component dependency of fsevents
yarn run build
cp -R public/ ../../public/
# Return to the prior directory
popd
- name: Commit and Add GH Pages
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CI: true
run: |
cd gh-pages
echo "cleaning up the prior files on the branch"
if [ ! -f .nojekyll ]
then
touch .nojekyll
rm -f _config.yml
fi
rm -f *.js webpack.stats.json styles-*.js styles-*.js.map webpack-runtime-*.js.map webpack-runtime-*.js manifest.webmanifest component---*.js* app-*.js*
rm -rf docs/node_modules docs/public docs/.cache
rm -rf favicon.svg
cp favicon-32x32.png favicon.svg
echo "Moving the files around for gh-pages"
cp -Rf ../public/* ./
# Make sure no sh files are posted, it'll block the promotion
find . -iname '*.sh' -delete
# Record the Build Date
date > build.txt
git config --global user.email "${GITHUB_ACTOR}@users.noreply.github.com"
git config --global user.name "Github Actions Bot - GH-Pages"
git add .
git commit -m "Automated gh-pages deployment: $(date -u)"
- name: Push changes to GH Pages
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CI: true
run: |
cd gh-pages
echo "Push Changes"
git branch
remote_repo="https://x-access-token:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git"
git push "${remote_repo}" HEAD:gh-pages
- name: Request GitHub Pages Build
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
# As documented here, the GH-Pages behavior changed, and the API must be 'Triggered'
# https://github.community/t5/GitHub-Actions/Github-action-not-triggering-gh-pages-upon-push/m-p/43192/highlight/true#M5281
curl -L -X POST -H "Content-Type: application/json" -H "Authorization: token ${GITHUB_TOKEN}" "https://api.github.com/repos/${GITHUB_REPOSITORY}/pages/builds"