|
| 1 | +# This syncs the GitHub Pages from the repo and presents it at https://secvisogram.github.io |
| 2 | + |
| 3 | +name: Secvisogram Website |
| 4 | + |
| 5 | +# Run only on schedule and manually |
| 6 | +on: |
| 7 | + workflow_dispatch: |
| 8 | + schedule: |
| 9 | + - cron: '37 6 * * *' |
| 10 | + |
| 11 | +env: |
| 12 | + RUN_NEEDED: true |
| 13 | + |
| 14 | +jobs: |
| 15 | + publish: |
| 16 | + runs-on: ubuntu-latest |
| 17 | + steps: |
| 18 | + - name: Check whether run is needed |
| 19 | + if: ${{ github.event_name != 'workflow_dispatch' }} |
| 20 | + run: | |
| 21 | + cd /tmp |
| 22 | + curl https://raw.githubusercontent.com/secvisogram/secvisogram.github.io/gh-pages/COMMITHASH > COMMITHASH.current |
| 23 | + curl https://raw.githubusercontent.com/secvisogram/secvisogram/gh-pages/COMMITHASH > COMMITHASH.source |
| 24 | + echo "Difference of Lines" |
| 25 | + bash -c 'diff COMMITHASH.current COMMITHASH.source | wc -l' |
| 26 | + test ` bash -c 'diff COMMITHASH.current COMMITHASH.source | wc -l' ` -eq 0 && echo "RUN_NEEDED=false" >> $GITHUB_ENV |
| 27 | + cd $GITHUB_WORKSPACE |
| 28 | + - name: Checkout current repo |
| 29 | + if: ${{ env.RUN_NEEDED == 'true' }} |
| 30 | + uses: actions/checkout@v2 |
| 31 | + - name: Checkout built GitHub Pages from Secvisogram repo |
| 32 | + if: ${{ env.RUN_NEEDED == 'true' }} |
| 33 | + uses: actions/checkout@v2 |
| 34 | + with: |
| 35 | + repository: secvisogram/secvisogram |
| 36 | + ref: gh-pages |
| 37 | + path: build |
| 38 | + - name: Remove .git directory to allow further process |
| 39 | + if: ${{ env.RUN_NEEDED == 'true' }} |
| 40 | + run: | |
| 41 | + cd build |
| 42 | + rm -rf .git |
| 43 | + - name: Deploy to GitHub Pages |
| 44 | + if: ${{ env.RUN_NEEDED == 'true' }} |
| 45 | + uses: crazy-max/ghaction-github-pages@v2 |
| 46 | + with: |
| 47 | + repo: secvisogram/secvisogram.github.io |
| 48 | + target_branch: gh-pages |
| 49 | + build_dir: build |
| 50 | + env: |
| 51 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments