-
Notifications
You must be signed in to change notification settings - Fork 15
62 lines (56 loc) · 2 KB
/
Copy pathpublish-design.yml
File metadata and controls
62 lines (56 loc) · 2 KB
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
name: publish-design
# Publish of design versions happens on push to master.
# Needs to include:
# * Design changes
# * Anything required to actually build a spec, e.g. scripts, package files:
# not required immediately, but will be required when a spec is published
# In practice, anything besides the actual published specs themselves
on:
push:
branches:
- master
paths-ignore:
- docs/builds/*
- docs/builds.json
jobs:
build:
if: github.repository == 'alaress/schoolbox-api-docs'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
ref: gh-pages
- uses: actions/checkout@v3
with:
ref: develop
- name: Push design to gh-pages branch
id: publish-design
run: |
# Commit on behalf of the github-actions bot
git config --global user.name "github-actions[bot]"
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
# Copy all files (excl. builds/, builds.json) into gh-pages repo
mkdir .staging/
cp -r ./* .staging/
# Copy hidden files too (excl. .git, .github)
cp .gitignore .staging/.gitignore
cp .redocly.yaml .staging/.redocly.yaml
# remove specs themselves
rm -rf .staging/docs/builds/
rm -f .staging/docs/builds.json
# move files from base commit to gh-pages
git checkout -- .
git checkout gh-pages
cp -r .staging/* .
cp .staging/.gitignore .gitignore
cp .staging/.redocly.yaml .redocly.yaml
rm -rf .staging/
# Commit and push: if there are no changes, do nothing
git add . .gitignore .redocly.yaml
CHANGES=`git diff --cached --shortstat`
if [ -n "${CHANGES}" ]; then
git commit -m "Build design for commit ${{ github.sha }}" .
git push
else
echo "no files changed; pushing nothing"
fi