Skip to content
This repository was archived by the owner on May 15, 2025. It is now read-only.

feat: ci to build new registry on push to main #363

Merged
merged 21 commits into from
Dec 19, 2024

Conversation

bcpeinhardt
Copy link
Collaborator

This PR adds a github actions workflow for deploying new revisions of the registry on pushes to main.
This means updating the new registry will continue to be as simple as landing a PR in this repo, but it should only take as long as the docker container takes to build to see the updates live :)

I don't love that cloud build wants me to pass the build secret and API key as query params but I went through the raw logs for the workflow and it doesn't get logged there.

branches:
- main

pull_request:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to deploy on each PR too?

Copy link
Collaborator Author

@bcpeinhardt bcpeinhardt Dec 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No I should pull that out, was moving too quickly, good catch 🙏

Comment on lines 25 to 30
# 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
Copy link
Member

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 gcloud CLI (ref: https://cloud.google.com/sdk/gcloud/reference/builds/triggers/run) in combination with the setup-gcloud action (https://github.com/google-github-actions/setup-gcloud)

Copy link
Member

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.

Copy link
Member

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

Copy link
Collaborator Author

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 😎

Copy link
Member

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

Comment on lines 32 to 37
# 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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this perhaps be a separate step in the workflow?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Honestly I would even consider removing it from the workflow. Since we have a dev environment now a little delay to review there might not be the worst thing.

push:
branches:
- main
- bcpeinhardt/ci-to-build-new-registry-on-push-to-main
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't forget to take this out.

Suggested change
- bcpeinhardt/ci-to-build-new-registry-on-push-to-main

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I'm still testing haha but thank you 🙏 putting this in draft until it's ready.

@bcpeinhardt bcpeinhardt marked this pull request as draft December 18, 2024 13:52
@bcpeinhardt bcpeinhardt marked this pull request as ready for review December 19, 2024 15:59
@bcpeinhardt
Copy link
Collaborator Author

Uh merging in main cause the git-clone test to fail. I don't think that was me but would appreciate a second look.

@bcpeinhardt bcpeinhardt merged commit 482ed84 into main Dec 19, 2024
2 checks passed
@bcpeinhardt bcpeinhardt deleted the bcpeinhardt/ci-to-build-new-registry-on-push-to-main branch December 19, 2024 19:25
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants