-
Notifications
You must be signed in to change notification settings - Fork 71
feat: migrate compute engine postdeployment to cloud build triggers #125
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
39 commits
Select commit
Hold shift + click to select a range
6fb537e
feat: migrate postdeployment to data http
glasnt 10a979e
lint
glasnt 2e55250
lint: add ignore to side-effect 'unused' data sources
glasnt 03741e2
WIP NO MERGE: progress on cloudbuild-based deployments
glasnt 751f8c3
WIP save
glasnt 2f0d20d
Merge branch 'main' into feat/postjsstrigger
glasnt b839b62
remove unused code
glasnt ba1d223
cleanup todos
glasnt 126c684
Add roles/pubsub.editor permissions
glasnt 9a95c4a
terraform format
glasnt 821bfb1
lint: trim whitespace
glasnt d2a720f
lint: ignore unused variable (for now)
glasnt 604bda4
Add roles/cloudbuild.builds.editor permissions
glasnt d3dbb07
bump avocano version
glasnt 323ef0e
bump avocano version
glasnt dc04522
use updated placeholder placeholder
glasnt cfd9c39
still use a client job, rather than a step.
glasnt c5830b3
move from distroless to ubuntu
glasnt 4b0a2da
fix: ensure correct workdir used when using image in cloudbuild
glasnt fdcd270
make all init jobs optional; (debug) use init sa for permissions
glasnt f4fffbe
update optional resources
glasnt 729b0a2
(maybe?) ensure broken placeholder looks identical to working init tr…
glasnt ae37622
lint
glasnt 7ed09e4
the trigger execution needs to wait for the permissions to land
glasnt c505dc2
cleanup depends, don't give client perms it doesn't need anymore
glasnt 0475b3a
add an wait to let iam consist eventually, attempt to fix race condit…
glasnt 469df4a
debug: wait longer, and for more debugs
glasnt 33ef1df
that's not a resource
glasnt 782f6b6
neither is that
glasnt fc1c236
debug: improve iam reliability by artificially staggering triggers
glasnt c2d094f
remove duplicate cloud run job declaration
glasnt 6d6a312
correct removal of tf-based client job
glasnt 75af1dc
correct syntax
glasnt 057953b
cleanup IAM, attempt to reduce concurrent policy changes
glasnt e74695c
lint, remove unused helpers
glasnt a75787e
fix syntax
glasnt 1bca6da
cleanup client job
glasnt f153dbc
init needs firebase admin
glasnt fecf354
create the client job as early as possible, hopefully helping tests
glasnt File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,14 +17,32 @@ | |
| # any errors? exit immediately. | ||
| set -e | ||
|
|
||
| # Ensure we got to the right directory. Cloud Build may start us in /workspace | ||
| cd /app | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. suggestion: I think it's cleaner to specify the directory in Cloud Build step than here, where setting the directory could complicate future use cases. |
||
|
|
||
| # escape if firebase_url not defined (mandatory, required later) | ||
| if [[ -z $FIREBASE_URL ]]; then | ||
| echo "FIREBASE_URL not defined. Cannot deploy. Exiting." | ||
| exit 1 | ||
| fi | ||
|
|
||
| # Only run the placeholder script if the site has been deployed before. | ||
| # Check if the firebase url has "Site Not Found" (the pre-deployment state) | ||
| if curl "$FIREBASE_URL" | grep -q "Site Not Found"; then | ||
| echo "Firebase site $FIREBASE_URL hasn't been deployed before, so it needs a placeholder." | ||
| else | ||
| echo "Firebase site $FIREBASE_URL has been deployed before. Not going to deploy placeholder. Exiting." | ||
| exit 0 | ||
| fi | ||
|
|
||
| # if deploying with a suffix (from infra/jobs.tf), adjust the config to suit the custom site | ||
| # https://firebase.google.com/docs/hosting/multisites#set_up_deploy_targets | ||
| if [[ -n $SUFFIX ]]; then | ||
| json -I -f firebase.json -e "this.hosting.target='$SUFFIX'" | ||
| UPDATED=true | ||
|
|
||
| # Use template file to generate configuration | ||
| envsubst < firebaserc.tmpl > .firebaserc | ||
| envsubst <firebaserc.tmpl >.firebaserc | ||
| echo "Customised .firebaserc created to support site." | ||
| cat .firebaserc | ||
| fi | ||
|
|
@@ -35,6 +53,10 @@ if [[ -n $UPDATED ]]; then | |
| cat firebase.json | ||
| fi | ||
|
|
||
| # Finally, deploy the application | ||
| echo "Deploying placeholder to Firebase..." | ||
|
|
||
| firebase deploy --project "$PROJECT_ID" --only hosting | ||
|
|
||
| # Setup for greater chances of success by explicitly purging cache | ||
| echo "Purging firebase cache" | ||
| curl -X PURGE "${FIREBASE_URL}/" | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Working out of a new directory seems safer, nice improvement.