|
| 1 | +on: [ push, pull_request, workflow_dispatch ] |
| 2 | + |
| 3 | +jobs: |
| 4 | + publish: |
| 5 | + runs-on: ubuntu-latest |
| 6 | + name: Publish Website |
| 7 | + steps: |
| 8 | + - name: Extract tag/branch variables |
| 9 | + shell: bash |
| 10 | + run: > |
| 11 | + echo "##[set-output name=tag;]$(echo ${GITHUB_REF#refs/tags/}|grep -v '/')"; |
| 12 | + echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/}|grep -v '/')"; |
| 13 | + id: extract |
| 14 | + - name: Write secret keys |
| 15 | + run: > |
| 16 | + echo "$FIREHOL_ORG_PUBLISH_SSH" > firehol_org_publish_key; |
| 17 | + chmod 600 firehol_org_publish_key; |
| 18 | + if [ -s firehol_org_publish_key ]; |
| 19 | + then |
| 20 | + eval "$(ssh-agent)"; |
| 21 | + ssh-add firehol_org_publish_key; |
| 22 | + echo "##[set-output name=has_ssh_key;]true"; |
| 23 | + echo "##[set-output name=ssh_agent_pid;]$SSH_AGENT_PID"; |
| 24 | + echo "##[set-output name=ssh_auth_sock;]$SSH_AUTH_SOCK"; |
| 25 | + fi; |
| 26 | + rm -f firehol_org_publish_key |
| 27 | + env: |
| 28 | + FIREHOL_ORG_PUBLISH_SSH: ${{secrets.FIREHOL_ORG_PUBLISH_SSH}} |
| 29 | + id: secret_keys |
| 30 | + - name: Skip branches which use a name reserved for use on the server |
| 31 | + if: >- |
| 32 | + ${{ steps.extract.outputs.branch == '' |
| 33 | + || steps.extract.outputs.branch == 'www' |
| 34 | + || steps.extract.outputs.branch == 'download' |
| 35 | + || steps.extract.outputs.branch == 'static' |
| 36 | + || steps.extract.outputs.branch == 'ssl' |
| 37 | + || steps.extract.outputs.branch == 'webalizer' |
| 38 | + || steps.extract.outputs.branch == 'tmp' }} |
| 39 | + run: > |
| 40 | + echo "Not publishing '${{steps.extract.outputs.branch}}'"; |
| 41 | + echo "##[set-output name=skip;]true" |
| 42 | + id: check |
| 43 | + - uses: actions/checkout@v2 |
| 44 | + - run: ./.github/workflows/setup.sh |
| 45 | + - run: make |
| 46 | + - name: Deploy website ${{steps.extract.outputs.branch}} |
| 47 | + if: ${{ steps.secret_keys.outputs.has_ssh_key && ! steps.check.outputs.skip }} |
| 48 | + run: ./.github/workflows/deploy-website.sh ${{steps.extract.outputs.branch}} |
| 49 | + env: |
| 50 | + SSH_AGENT_PID: ${{ steps.secret_keys.outputs.ssh_agent_pid }} |
| 51 | + SSH_AUTH_SOCK: ${{ steps.secret_keys.outputs.ssh_auth_sock }} |
| 52 | + - name: Check deployment |
| 53 | + if: ${{ steps.secret_keys.outputs.has_ssh_key && ! steps.check.outputs.skip }} |
| 54 | + run: > |
| 55 | + sleep 300; |
| 56 | + curl -q -o- https://firehol.org/travis-website.log |
0 commit comments