Skip to content

Merge pull request #217 from alaress/task-master/SA-22075 #71

Merge pull request #217 from alaress/task-master/SA-22075

Merge pull request #217 from alaress/task-master/SA-22075 #71

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