1- # This workflow build and push a Docker container to Google Artifact Registry
2- # and deploy it on Cloud Run when a commit is pushed to the "main"
3- # branch.
4- #
5- # To configure this workflow:
6- #
7- # 1. Enable the following Google Cloud APIs:
8- #
9- # - Artifact Registry (artifactregistry.googleapis.com)
10- # - Cloud Run (run.googleapis.com)
11- # - IAM Credentials API (iamcredentials.googleapis.com)
12- #
13- # You can learn more about enabling APIs at
14- # https://support.google.com/googleapi/answer/6158841.
15- #
16- # 2. Create and configure a Workload Identity Provider for GitHub:
17- # https://github.com/google-github-actions/auth#preferred-direct-workload-identity-federation.
18- #
19- # Depending on how you authenticate, you will need to grant an IAM principal
20- # permissions on Google Cloud:
21- #
22- # - Artifact Registry Administrator (roles/artifactregistry.admin)
23- # - Cloud Run Developer (roles/run.developer)
24- #
25- # You can learn more about setting IAM permissions at
26- # https://cloud.google.com/iam/docs/manage-access-other-resources
27- #
28- # 3. Change the values in the "env" block to match your values.
1+ # This workflow uses devbox for dependency management and builds/deploys the builder API
2+ # to Cloud Run when a commit is pushed to the "main" branch.
293
30- name : ' Build and Deploy to Cloud Run'
4+ name : ' Build and Deploy Builder API to Cloud Run'
315
326on :
337 push :
348 branches :
359 - main
3610 paths :
3711 - ' builder-api/**'
12+ - ' devbox.json'
13+ - ' devbox.lock'
3814
3915env :
4016 PROJECT_ID : ' benefit-decision-toolkit-play'
@@ -53,43 +29,39 @@ jobs:
5329
5430 steps :
5531 - name : ' Checkout'
56- uses : ' actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332' # actions/checkout@v4
57-
58-
59- # Configure Workload Identity Federation and generate an access token.
60- #
61- # See https://github.com/google-github-actions/auth for more options,
62- # including authenticating via a JSON credentials file.
32+ uses : ' actions/checkout@v4'
33+
34+ # Devbox needs a .env file to exist, even if it's empty
35+ # TODO: Make this useful in this and other workflows by just consolidating env vars
36+ # here (so that we don't need to manage multiple places)
37+ - name : ' Create .env file'
38+ run : touch .env
39+
40+ # Setup devbox which includes all our dependencies: Maven, JDK 21, Quarkus, etc.
41+ - name : ' Install devbox'
42+ uses :
' jetify-com/[email protected] ' 43+ with :
44+ enable-cache : true
45+
46+ # Configure Workload Identity Federation and generate an access token
6347 - id : ' auth'
6448 name : ' Authenticate to Google Cloud'
6549 uses : ' google-github-actions/auth@v2'
6650 with :
6751 workload_identity_provider : ' ${{ env.WORKLOAD_IDENTITY_PROVIDER }}'
6852 service_account : cicd-build-deploy-api@benefit-decision-toolkit-play.iam.gserviceaccount.com
6953 project_id : ${{ env.PROJECT_ID }}
70-
71- - name : ' Set up Cloud SDK'
72- uses : ' google-github-actions/setup-gcloud@v2'
73-
74- # BEGIN - Docker auth and build
7554
76- # Configure Docker to use gcloud as a credential helper
55+ # Configure Docker to use gcloud as a credential helper (using devbox gcloud)
7756 - name : ' Configure Docker'
7857 run : |
79- gcloud auth configure-docker ${{ env.REGION }}-docker.pkg.dev
80-
81- # Download Java version
82- - name : Set up Java 21
83- uses : actions/setup-java@v3
84- with :
85- distribution : temurin
86- java-version : 21
58+ devbox run -- gcloud auth configure-docker ${{ env.REGION }}-docker.pkg.dev
8759
88- # Build the Quarkus app with Maven
60+ # Build the Quarkus app with Maven using devbox environment
8961 - name : ' Build Quarkus App'
9062 working-directory : builder-api
9163 run : |
92- ./mvnw package -DskipTests
64+ devbox run build-builder-api-ci
9365
9466 - name : ' Build and Push Container'
9567 working-directory : builder-api
@@ -99,21 +71,18 @@ jobs:
9971 docker push "${DOCKER_TAG}"
10072
10173 - name : ' Deploy to Cloud Run'
102-
103- # END - Docker auth and build
104-
105- uses : ' google-github-actions/deploy-cloudrun@33553064113a37d688aa6937bacbdc481580be17' # google-github-actions/deploy-cloudrun@v2
74+ uses : ' google-github-actions/deploy-cloudrun@v2'
10675 with :
10776 service : ' ${{ env.API_NAME }}'
10877 region : ' ${{ env.REGION }}'
109- # NOTE: If using a pre-built image, update the image name below:
110-
11178 image : ' ${{ env.REGION }}-docker.pkg.dev/${{ env.PROJECT_ID }}/${{ env.SERVICE }}/${{ env.API_NAME }}:latest'
11279 service_account : ' builder-api-service-account@${{ env.PROJECT_ID }}.iam.gserviceaccount.com'
11380 flags : ' --allow-unauthenticated --max-instances=2'
81+ env_vars : |
82+ QUARKUS_GOOGLE_CLOUD_PROJECT_ID=${{ env.PROJECT_ID }}
83+ GCS_BUCKET_NAME=${{ env.PROJECT_ID }}.firebasestorage.app
11484
11585 # If required, use the Cloud Run URL output in later steps
11686 - name : ' Show output'
117- run : |2-
118-
119- echo ${{ steps.deploy.outputs.url }}
87+ run : |
88+ echo ${{ steps.deploy.outputs.url }}
0 commit comments