--- (#16) #9
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
name: Deploy Documentation | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
deploy: | |
runs-on: ubuntu-22.04 | |
environment: Production | |
steps: | |
- name: Download html artifact | |
run: | | |
repo="${{ github.repository }}" | |
workflow="build_and_test.yml" | |
artifact="html" | |
run_id=`gh run --repo ${repo} list --workflow ${workflow} --json databaseId --jq .[0].databaseId` | |
mkdir html | |
cd html | |
gh run --repo ${repo} download ${run_id} -n ${artifact} | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Commit documentation changes | |
run: | | |
git clone https://github.com/${{ github.repository }}.git --branch gh-pages --single-branch gh-pages | |
cd gh-pages | |
rm -rf * | |
cp -r ../html/* . | |
git config --local user.email "action@github.com" | |
git config --local user.name "GitHub Action" | |
git add . | |
git commit -m "Update documentation" -a || true | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Push changes | |
uses: ad-m/github-push-action@master | |
with: | |
branch: gh-pages | |
directory: gh-pages | |
github_token: ${{ secrets.GITHUB_TOKEN }} |