msfjarvis.dev/.github/workflows/deploy.yml

53 lines
1.8 KiB
YAML

name: Hugo deployment
on:
push:
branches:
- src
jobs:
build-deploy:
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@master
- name: Setup Hugo
uses: peaceiris/actions-hugo@v2.2.2
with:
hugo-version: '0.62.0'
extended: true
- name: Build staging
run: hugo --minify -DEFb=https://staging.msfjarvis.dev/
- name: Deploy to staging
if: "!contains(github.event.head_commit.message, '[skip staging]') && !contains(github.event.head_commit.message, '[skip deploy]')"
run: source $GITHUB_WORKSPACE/ci/deploy.sh
env:
ACTIONS_DEPLOY_KEY: ${{ secrets.ACTIONS_DEPLOY_KEY }}
SSH_USERNAME: ${{ secrets.SSH_USERNAME }}
SERVER_ADDRESS: ${{ secrets.SERVER_ADDRESS }}
SERVER_DESTINATION: ${{ secrets.SERVER_DESTINATION_STAGING }}
SSH_PORT: ${{ secrets.SSH_PORT }}
- name: Build prod
run: hugo --minify
- name: Deploy to prod
if: "!contains(github.event.head_commit.message, '[skip prod]') && !contains(github.event.head_commit.message, '[skip deploy]')"
run: source $GITHUB_WORKSPACE/ci/deploy.sh
env:
ACTIONS_DEPLOY_KEY: ${{ secrets.ACTIONS_DEPLOY_KEY }}
SSH_USERNAME: ${{ secrets.SSH_USERNAME }}
SERVER_ADDRESS: ${{ secrets.SERVER_ADDRESS }}
SERVER_DESTINATION: ${{ secrets.SERVER_DESTINATION_PROD }}
SSH_PORT: ${{ secrets.SSH_PORT }}
- name: Purge Cloudflare cache
run: |
curl -s -X POST "https://api.cloudflare.com/client/v4/zones/${CF_ZONE_ID}/purge_cache" -H "X-Auth-Email: msfjarvis@gmail.com" -H "X-Auth-Key: ${CF_API_KEY}" -H "Content-Type: application/json" --data '{"purge_everything":true}'
env:
CF_API_KEY: ${{ secrets.CLOUDFLARE_API_KEY }}
CF_ZONE_ID: ${{ secrets.CLOUDFLARE_ZONE_ID }}