-
Notifications
You must be signed in to change notification settings - Fork 62
feat: ci to build new registry on push to main #363
Changes from 9 commits
f52b8ca
3e2128c
df92e31
233775e
ca69c68
1d9288a
0b73692
374e8de
ee83bb2
58ab394
e86e50c
d9622e5
c262bec
e8461fd
e36e66b
3b04b61
48b9b5b
236439c
41a89e2
86d144e
019c690
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| #!/usr/bin/env bash | ||
| set -o pipefail | ||
| set -u | ||
|
|
||
| VERBOSE="${VERBOSE:-0}" | ||
| if [[ "${VERBOSE}" -ne "0" ]]; then | ||
| set -x | ||
| fi | ||
|
|
||
| # List of required environment variables | ||
| required_vars=( | ||
| "GCLOUD_API_KEY" | ||
| "GCLOUD_PROD_DEPLOY_SECRET" | ||
| "GCLOUD_DEV_DEPLOY_SECRET" | ||
| ) | ||
|
|
||
| # Check if each required variable is set | ||
| for var in "${required_vars[@]}"; do | ||
| if [[ -z "${!var:-}" ]]; then | ||
| echo "Error: Environment variable '$var' is not set." | ||
| exit 1 | ||
| fi | ||
| done | ||
|
|
||
| # Trigger a build for dev | ||
| # DONT EVER SET ANY FLAGS THAT MIGHT PRINT THE URL, AS IT HAS SECRETS IN IT | ||
| curl -X POST "https://cloudbuild.googleapis.com/v1/projects/coder-registry-1/triggers/http-build-registry-v2-dev:webhook?key=${GCLOUD_API_KEY}&secret=${GCLOUD_DEV_DEPLOY_SECRET}" \ | ||
| -H "Content-Type: application/json" \ | ||
| -d '{}' \ | ||
| --fail | ||
|
|
||
| # Trigger a build for prod | ||
| # DONT EVER SET ANY FLAGS THAT MIGHT PRINT THE URL, AS IT HAS SECRETS IN IT | ||
| curl -X POST "https://cloudbuild.googleapis.com/v1/projects/coder-registry-1/triggers/http-build-registry-v2-trigger:webhook?key=${GCLOUD_API_KEY}&secret=${GCLOUD_PROD_DEPLOY_SECRET}" \ | ||
| -H "Content-Type: application/json" \ | ||
| -d '{}' \ | ||
| --fail | ||
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| name: deploy-registry | ||
|
|
||
| on: | ||
| push: | ||
| branches: | ||
| - main | ||
|
|
||
| pull_request: | ||
|
||
| workflow_dispatch: | ||
|
|
||
| jobs: | ||
| deploy: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Run deploy-registry.sh | ||
| run: | | ||
| ./.github/scripts/deploy-registry.sh | ||
| env: | ||
| GCLOUD_API_KEY: ${{ secrets.GCLOUD_API_KEY }} | ||
| GCLOUD_PROD_DEPLOY_SECRET: ${{ secrets.GCLOUD_PROD_DEPLOY_SECRET }} | ||
| GCLOUD_DEV_DEPLOY_SECRET: ${{ secrets.GCLOUD_DEV_DEPLOY_SECRET }} | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not entirely convinced about this approach. We could maybe instead trigger a build using the
gcloudCLI (ref: https://cloud.google.com/sdk/gcloud/reference/builds/triggers/run) in combination with thesetup-gcloudaction (https://github.com/google-github-actions/setup-gcloud)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cc @deansheather for some additional eyes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Absolutely would prefer to use gcloud CLI rather than calling googleapis from curl. We also should not be using service account credentials as actions secrets, and should use workload identity instead. I can help you set that up with a new SA for this repo @bcpeinhardt
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Secrets deleted, will update to use the gcloud cli, and yes some help with a service account would be great haha 😎
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll message you on Slack