mirror of
https://github.com/msfjarvis/msfjarvis.dev.git
synced 2024-06-03 04:18:56 +05:30
77 lines
2.4 KiB
YAML
77 lines
2.4 KiB
YAML
name: Deploy
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- src
|
|
|
|
jobs:
|
|
build-deploy:
|
|
runs-on: ubuntu-18.04
|
|
if: "!contains(github.event.head_commit.message, '[skip deploy]')"
|
|
steps:
|
|
- uses: actions/checkout@master
|
|
|
|
- name: Setup Hugo
|
|
uses: peaceiris/actions-hugo@v2.2.2
|
|
with:
|
|
hugo-version: '0.71.1'
|
|
extended: true
|
|
|
|
- name: Build staging
|
|
if: "!contains(github.event.head_commit.message, '[skip staging]')"
|
|
run: hugo --minify -DEFb=https://staging.msfjarvis.dev/
|
|
|
|
- name: Deploy to staging
|
|
if: "!contains(github.event.head_commit.message, '[skip staging]')"
|
|
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
|
|
if: "!contains(github.event.head_commit.message, '[skip prod]')"
|
|
run: |
|
|
rm -rf public/
|
|
hugo --minify
|
|
|
|
- name: Deploy to prod
|
|
if: "!contains(github.event.head_commit.message, '[skip prod]')"
|
|
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 }}
|
|
|
|
lighthouse:
|
|
runs-on: ubuntu-latest
|
|
needs: [build-deploy]
|
|
steps:
|
|
- name: Audit URL using Lighthouse
|
|
uses: docker://jakejarvis/lighthouse-action:latest
|
|
with:
|
|
url: 'https://msfjarvis.dev/'
|
|
- name: Upload results as an artifact
|
|
uses: actions/upload-artifact@master
|
|
with:
|
|
name: report
|
|
path: './report'
|
|
|
|
purge-cloudflare-cache:
|
|
runs-on: ubuntu-18.04
|
|
if: "contains(github.event.head_commit.message, '[purge cache]')"
|
|
steps:
|
|
- 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: me@msfjarvis.dev" -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 }}
|