ci(ga): trigger cloudflare & netlify from github

if gitlab is down
This commit is contained in:
MDLeom 2022-01-25 09:48:43 +00:00
parent 1f79224b32
commit fca89a75a4
No known key found for this signature in database
GPG Key ID: 32D3E28E96A695E8
2 changed files with 31 additions and 1 deletions

View File

@ -8,7 +8,7 @@ on:
jobs:
pages:
runs-on: ubuntu-latest
container: alpine:latest
container: node:lts-alpine
steps:
- uses: actions/checkout@v2
- name: Install Dependencies
@ -33,3 +33,23 @@ jobs:
name: artifacts
path: ./tmp/
retention-days: 30
- name: Check GitLab Status
env:
GITHUB_ENV: ${{ env.GITHUB_ENV }}
run: sh ./src/gitlab_status.sh
- name: Cloudflare Pages
env:
CLOUDFLARE_BUILD_HOOK: ${{ secrets.CLOUDFLARE_BUILD_HOOK }}
if: ${{ env.CLOUDFLARE_BUILD_HOOK != 0 && env.GITLAB_STATUS == 'down' }}
run: curl -X POST "https://api.cloudflare.com/client/v4/pages/webhooks/deploy_hooks/${{ env.CLOUDFLARE_BUILD_HOOK }}"
- name: Netlify
env:
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
if: ${{ env.NETLIFY_SITE_ID != 0 && env.GITLAB_STATUS == 'down' }}
run: |
npm install
npm install netlify-cli -g
netlify --telemetry-disable
npm run build
netlify deploy --dir=public --prod

10
src/gitlab_status.sh Normal file
View File

@ -0,0 +1,10 @@
#!/bin/sh
CURL_STATUS=$(curl -sSIL "https://gitlab.com/curben/urlhaus-filter/-/nonsense" | grep -F "HTTP/2 200")
GITLAB_STATUS="up"
if [ -z "$CURL_STATUS" ]; then
GITLAB_STATUS="down"
fi
echo "GITLAB_STATUS=$GITLAB_STATUS" >> "$GITHUB_ENV"