|
| 1 | +name: Update pages |
| 2 | +on: [push] |
| 3 | + |
| 4 | +jobs: |
| 5 | + update-web: |
| 6 | + runs-on: ubuntu-latest |
| 7 | + steps: |
| 8 | + - uses: actions/checkout@v2 |
| 9 | + - uses: actions/setup-python@v2 |
| 10 | + with: |
| 11 | + python-version: '3.8' |
| 12 | + - name: Publish pages to web |
| 13 | + shell: bash |
| 14 | + env: |
| 15 | + encrypted_54b6162b97cf_key: ${{ secrets.encrypted_key }} |
| 16 | + encrypted_54b6162b97cf_iv: ${{ secrets.encrypted_iv }} |
| 17 | + run: | |
| 18 | + # Only build the "source" branch ("master" = built, published pages, |
| 19 | + # this can't be changed for organization GitHub Pages) |
| 20 | + test ${GITHUB_REF##*/} == "source" || exit 0 |
| 21 | + |
| 22 | + # Install dependency |
| 23 | + pip install docutils |
| 24 | + |
| 25 | + # Add git metadata |
| 26 | + git config user.name "Automated build" |
| 27 | + git config user.email "[email protected]" |
| 28 | +
|
| 29 | + # Build the pages |
| 30 | + make clean |
| 31 | + make |
| 32 | +
|
| 33 | + # Delete workflow for the output ("master") branch, |
| 34 | + # so GitHub won't even trigger a build for it. |
| 35 | + rm .github/workflows/main.yml |
| 36 | + git add --all . |
| 37 | + git commit -m "Automatically built pages at $(git rev-parse --short HEAD)" || exit 0 |
| 38 | +
|
| 39 | + # travis/github_deploy_key.enc is an encrypted SSH key. |
| 40 | + # The keys for this key are stored with GitHub and are exposed in the |
| 41 | + # $encrypted... environment variables. (These are *not* available in pull request builds!) |
| 42 | + # The public key is set up as a deployment key in the GitHub repository. |
| 43 | + # The following document explains the process: |
| 44 | + # https://docs.github.com/en/free-pro-team@latest/actions/reference/encrypted-secrets |
| 45 | + openssl aes-256-cbc -K $encrypted_54b6162b97cf_key -iv $encrypted_54b6162b97cf_iv -in .travis/github_deploy_key.enc -out github_deploy_key -d |
| 46 | +
|
| 47 | + # Add the SSH key |
| 48 | + chmod 600 github_deploy_key |
| 49 | + eval `ssh-agent -s` |
| 50 | + ssh-add github_deploy_key |
| 51 | +
|
| 52 | + # Push changes to the *master* branch |
| 53 | + # Remember, this is building the *source* branch. |
| 54 | + git push --force [email protected]:borgbackup/borgbackup.github.io.git HEAD:master |
| 55 | +
|
| 56 | + # Kill SSH agent, get rid of the key (GitHub does that as well) |
| 57 | + kill $SSH_AGENT_PID |
| 58 | + shred -u github_deploy_key |
0 commit comments