Update GitHub Actions workflow #23
This file contains hidden or 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: CI | |
| on: | |
| push: | |
| branches-ignore: gh-pages | |
| pull_request: | |
| branches-ignore: gh-pages | |
| jobs: | |
| deploy: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v2 | |
| - name: Create gh-pages directory | |
| run: mkdir -p generation/gh-pages | |
| - name: Install dependencies | |
| run: sudo apt-get install m4 graphviz | |
| - name: "Generate C++20 flowcharts" | |
| run: | | |
| out='generation/gh-pages/std-2020' | |
| mkdir -- "$out" | |
| m4 cpp20/flowchart.dot.m4 | dot -Tsvg -start=1000 > "$out"/initialization.svg | |
| m4 cpp20/flowchart.dot.m4 | dot -Tpng -start=1000 > "$out"/initialization.png | |
| # Backwards compatibility with old output. | |
| ln -s -- "$out/initialization.svg" generation/gh-pages/initialization.svg | |
| ln -s -- "$out/initialization.png" generation/gh-pages/initialization.png | |
| - name: "Generate C++23 flowcharts" | |
| run: | | |
| out='generation/gh-pages/std-2023' | |
| mkdir -- "$out" | |
| cat cpp23/flowchart.dot.cpp | gcc -E - | dot -Tsvg -start=1000 > "$out"/initialization.svg | |
| cat cpp23/flowchart.dot.cpp | gcc -E - | dot -Tpng -start=1000 > "$out"/initialization.png | |
| - name: Deploy generated flowcharts to Github Pages | |
| if: github.ref == 'refs/heads/main' | |
| run: | | |
| # Set Git committer identity | |
| git config user.name "ci-build" | |
| git config user.email "[email protected]" | |
| # Clear the index | |
| EMPTY_TREE="$(git hash-object -t tree /dev/null)" | |
| git read-tree -- "$EMPTY_TREE" | |
| # Add site data to index | |
| git add generation/gh-pages | |
| git fetch origin gh-pages | |
| ORIG_SITE_TREE="$(git rev-parse origin/gh-pages^{tree})" | |
| NEW_SITE_TREE="$(git write-tree --prefix=generation/gh-pages)" | |
| if [ "$ORIG_SITE_TREE" != "$NEW_SITE_TREE" ]; then | |
| SITE_COMMIT="$(git commit-tree -p origin/gh-pages -m "CI updates" -- "$NEW_SITE_TREE")" | |
| echo Updating GitHub pages site to commit "$SITE_COMMIT" | |
| git push origin "$SITE_COMMIT":gh-pages | |
| else | |
| echo Not updating GitHub pages site | |
| fi |