Publish mmstudio/latest #194
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# When a push is made to any branch named pages/<project>/<version>, update | |
# the gh-pages branch with a copy of the newly pushed content. | |
name: Publish | |
on: | |
push: | |
branches: | |
- 'pages/**' | |
concurrency: | |
# Prevent overlapping runs of this workflow, which would cause a race on the | |
# gh-pages branch. | |
group: publish-to-gh-pages | |
cancel-in-progress: false | |
jobs: | |
update-html: | |
name: Update docs for project/version | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
with: | |
fetch-depth: 0 # All refs and history | |
path: apidoc | |
- run: | | |
pages_ref=${{ github.ref }} # refs/heads/pages/proj/ver | |
pages_branch=${pages_ref#refs/heads/} # pages/proj/ver | |
pages_path=${pages_branch#pages/} # proj/ver | |
cd apidoc | |
git archive -o ../pages.tar $pages_branch | |
if ! git checkout gh-pages --; then | |
git checkout --orphan gh-pages | |
git rm -rf . | |
else | |
git rm -rf --ignore-unmatch $pages_path | |
fi | |
mkdir -p $pages_path | |
tar xf ../pages.tar -C $pages_path | |
rm -rf $pages_path/.github | |
git add $pages_path | |
git config user.name 'github-actions[bot]' | |
git config user.email '41898282+github-actions[bot]@users.noreply.github.com' | |
if [ -z "$(git status --porcelain=v1 2>/dev/null)" ]; then | |
echo "No changes to commit" | |
else | |
git commit -m "Autoupdate $pages_path" | |
git push -u origin gh-pages | |
fi |