forked from PinSpace-Org/GistPin
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpre-deploy-checks.yml
More file actions
105 lines (97 loc) 路 3.58 KB
/
Copy pathpre-deploy-checks.yml
File metadata and controls
105 lines (97 loc) 路 3.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
name: Pre-Deploy Dependency Health Checks
# Reusable gate that every deploy pipeline (deploy-dev.yml, deploy-staging.yml,
# deploy-production.yml) calls before touching the target environment. Blocks
# the deploy if a critical dependency (database, Soroban RPC) is unhealthy.
#
# Called from another workflow like:
#
# jobs:
# pre-deploy-checks:
# uses: ./infrastructure/ci/pre-deploy-checks.yml
# with:
# environment: staging
# secrets: inherit
#
# deploy-staging:
# needs: pre-deploy-checks
# ...
on:
workflow_call:
inputs:
environment:
description: 'Target environment (dev, staging, production)'
required: true
type: string
emergency_bypass:
description: 'Skip the blocking gate if a dependency is unhealthy'
required: false
type: boolean
default: false
emergency_reason:
description: 'Required justification when emergency_bypass is true'
required: false
type: string
default: ''
workflow_dispatch:
inputs:
environment:
description: 'Target environment (dev, staging, production)'
required: true
type: choice
options: [dev, staging, production]
emergency_bypass:
description: 'Skip the blocking gate if a dependency is unhealthy'
required: false
type: boolean
default: false
emergency_reason:
description: 'Required justification when emergency_bypass is true'
required: false
type: string
default: ''
jobs:
check-dependencies:
name: Check Infrastructure Dependencies (${{ inputs.environment }})
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Validate emergency bypass input
if: ${{ inputs.emergency_bypass && inputs.emergency_reason == '' }}
run: |
echo "emergency_bypass is true but emergency_reason was not provided."
echo "A reason is required so the bypass is auditable. Aborting."
exit 1
- name: Install dependencies
run: |
sudo apt-get update -y
sudo apt-get install -y jq postgresql-client
- name: Run dependency health checks
id: health-checks
env:
DATABASE_HOST: ${{ secrets.DATABASE_HOST }}
DATABASE_PORT: ${{ secrets.DATABASE_PORT }}
DATABASE_NAME: ${{ secrets.DATABASE_NAME }}
DATABASE_USER: ${{ secrets.DATABASE_USER }}
DATABASE_PASSWORD: ${{ secrets.DATABASE_PASSWORD }}
SOROBAN_RPC_URL: ${{ vars.SOROBAN_RPC_URL }}
IPFS_GATEWAY: ${{ vars.IPFS_GATEWAY }}
PINATA_API_KEY: ${{ secrets.PINATA_API_KEY }}
PINATA_SECRET_KEY: ${{ secrets.PINATA_SECRET_KEY }}
EMERGENCY_BYPASS: ${{ inputs.emergency_bypass }}
EMERGENCY_REASON: ${{ inputs.emergency_reason }}
run: |
bash infrastructure/scripts/check-dependencies.sh
- name: Upload dependency health report
if: always()
uses: actions/upload-artifact@v4
with:
name: dependency-health-${{ inputs.environment }}
path: infrastructure/ci/reports/dependency-health-*.json
retention-days: 30
- name: Notify on block
if: failure()
run: |
echo "Deploy to ${{ inputs.environment }} blocked: one or more infrastructure dependencies are unhealthy."
echo "See the dependency-health report artifact for details."
echo "To bypass for a genuine emergency, re-run with emergency_bypass=true and a emergency_reason."