-
Notifications
You must be signed in to change notification settings - Fork 2
190 lines (173 loc) · 6.27 KB
/
sync.yml
File metadata and controls
190 lines (173 loc) · 6.27 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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
# Sync capabilities to the Dreadnode platform using the SDK CLI.
#
# Layout: capabilities/{capability}/capability.yaml.
# All capabilities sync under the dreadnode organization.
#
# Promotion:
# push to main -> dev (auto, via Tailscale) + staging (auto) + prod (approval gate)
# workflow_dispatch -> selected environment(s)
#
# The SDK CLI does its own content-hash comparison and only uploads
# capabilities whose contents actually changed — so the workflow runs
# unconditionally on every push to main and lets the CLI decide what's
# new.
#
# Dev API is on an internal-only ALB — the dev sync job connects via Tailscale
# to reach dev.app.dreadnode.io through the dev bastion's subnet route.
# Requires TAILSCALE_OAUTH_CLIENT_ID + TAILSCALE_OAUTH_SECRET in the "dev"
# environment, tag-scoped to tag:ci-dev.
name: Sync Capabilities
on:
push:
branches: [main]
workflow_dispatch:
inputs:
environment:
description: "Target environment (or 'all')"
required: true
type: choice
options: [dev, staging, prod, all]
default: dev
force:
description: "Force upload even if SHA matches"
required: false
type: boolean
default: false
concurrency:
group: sync-${{ github.ref }}
cancel-in-progress: false
permissions:
contents: read
jobs:
validate:
name: Validate capabilities
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: astral-sh/setup-uv@v6
with:
enable-cache: true
- name: Validate
run: |
# TODO: restore --strict once two upstream issues are resolved:
# 1. Capability import errors fixed in this repo (bloodhound-enterprise,
# oss-fuzz-crs, sast — all reference removed/renamed SDK modules).
# 2. SDK change in dreadnode-tiger so `check:*` runtime tool checks
# don't run during validation — those probe for installed CLIs
# (nuclei, pdtm, caido-cli, etc.) which aren't on a clean runner
# and shouldn't gate validation.
# Without --strict, validation still fails on hard errors (import
# crashes, missing manifests) but warnings don't block the sync.
uv run --with dreadnode dreadnode capability validate capabilities
sync-dev:
name: "Sync to dev"
needs: validate
if: >-
github.event.inputs.environment == 'all' ||
github.event.inputs.environment == 'dev' ||
github.event_name == 'push'
runs-on: ubuntu-latest
environment: dev
steps:
- uses: actions/checkout@v4
# The dev API ALB is internal-only. Tailscale brings the runner onto
# the tailnet so it can route to dev.app.dreadnode.io via the dev
# bastion's subnet route. OAuth client must be tag-scoped to
# tag:ci-dev only — see policy.
- name: Connect to Tailscale
uses: tailscale/github-action@6cae46e2d796f265265cfcf628b72a32b4d7cade # v3
with:
oauth-client-id: ${{ secrets.TAILSCALE_OAUTH_CLIENT_ID }}
oauth-secret: ${{ secrets.TAILSCALE_OAUTH_SECRET }}
tags: tag:ci-dev
- uses: astral-sh/setup-uv@v6
with:
enable-cache: true
- name: Sync capabilities
env:
API_URL: ${{ vars.DREADNODE_API_URL }}
API_KEY: ${{ secrets.DREADNODE_API_KEY }}
FORCE: ${{ inputs.force || 'false' }}
run: |
set -euo pipefail
cmd=(uv run --with dreadnode dreadnode capability sync capabilities)
cmd+=(--server "${API_URL}" --api-key "${API_KEY}" --organization dreadnode)
cmd+=(--publish)
[[ "${FORCE}" == "true" ]] && cmd+=(--force)
"${cmd[@]}"
sync-staging:
name: "Sync to staging"
needs: validate
if: >-
github.event.inputs.environment == 'all' ||
github.event.inputs.environment == 'staging' ||
github.event_name == 'push'
runs-on: ubuntu-latest
environment: staging
steps:
- uses: actions/checkout@v4
- uses: astral-sh/setup-uv@v6
with:
enable-cache: true
- name: Sync capabilities
env:
API_URL: ${{ vars.DREADNODE_API_URL }}
API_KEY: ${{ secrets.DREADNODE_API_KEY }}
FORCE: ${{ inputs.force || 'false' }}
run: |
set -euo pipefail
cmd=(uv run --with dreadnode dreadnode capability sync capabilities)
cmd+=(--server "${API_URL}" --api-key "${API_KEY}" --organization dreadnode)
cmd+=(--publish)
[[ "${FORCE}" == "true" ]] && cmd+=(--force)
"${cmd[@]}"
sync-prod:
name: "Sync to prod"
needs: validate
if: >-
github.event.inputs.environment == 'all' ||
github.event.inputs.environment == 'prod' ||
github.event_name == 'push'
runs-on: ubuntu-latest
environment: prod
steps:
- uses: actions/checkout@v4
- uses: astral-sh/setup-uv@v6
with:
enable-cache: true
- name: Sync capabilities
env:
API_URL: ${{ vars.DREADNODE_API_URL }}
API_KEY: ${{ secrets.DREADNODE_API_KEY }}
FORCE: ${{ inputs.force || 'false' }}
run: |
set -euo pipefail
cmd=(uv run --with dreadnode dreadnode capability sync capabilities)
cmd+=(--server "${API_URL}" --api-key "${API_KEY}" --organization dreadnode)
cmd+=(--publish)
[[ "${FORCE}" == "true" ]] && cmd+=(--force)
"${cmd[@]}"
summary:
name: Sync summary
needs: [validate, sync-dev, sync-staging, sync-prod]
if: always()
runs-on: ubuntu-latest
steps:
- name: Report
env:
VALIDATE: ${{ needs.validate.result }}
DEV: ${{ needs.sync-dev.result }}
STAGING: ${{ needs.sync-staging.result }}
PROD: ${{ needs.sync-prod.result }}
run: |
{
echo "### Sync Summary"
echo "- **Validate:** ${VALIDATE}"
echo "- **Dev:** ${DEV}"
echo "- **Staging:** ${STAGING}"
echo "- **Prod:** ${PROD}"
} >> "$GITHUB_STEP_SUMMARY"
if [[ "${VALIDATE}" == "failure" || "${DEV}" == "failure" || "${STAGING}" == "failure" || "${PROD}" == "failure" ]]; then
echo "::error::One or more jobs failed"
exit 1
fi