-
Notifications
You must be signed in to change notification settings - Fork 8
Deploy via Cloud run #664
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
Open
Sparrow0hawk
wants to merge
8
commits into
main
Choose a base branch
from
terraform
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Deploy via Cloud run #664
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
060c337
Add terraform backend GCS storage for browse page
Sparrow0hawk 2c5b5d7
Add package.json script for terraform formatting
Sparrow0hawk f22e691
Add docker repository for browse page
Sparrow0hawk 31fce1c
Build and push Docker image after full CI workflow
Sparrow0hawk 26220f9
Import terraform for Cloud Storage bucket
Sparrow0hawk 0260f84
Add service running in Cloud Run
Sparrow0hawk edda0cd
Deploy new cloud run revision after every CI run to dev
Sparrow0hawk 2a3fb38
Extract a docker tag when CI is triggered by a pull request
Sparrow0hawk 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
Some comments aren't visible on the classic Files Changed page.
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,105 @@ | ||
| name: CI | ||
|
|
||
| on: | ||
| push: | ||
| branches: [ main ] | ||
| pull_request: | ||
| branches: [ main ] | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| env: | ||
| VITE_MAPTILER_API_KEY: '${{ secrets.MAPTILER_API_KEY }}' | ||
| IMAGE_PROJECT: dft-rlg-atip-dev | ||
| IMAGE_LOCATION: europe-west1 | ||
| IMAGE_REPOSITORY_ID: docker | ||
| IMAGE_NAME: plan | ||
|
|
||
| jobs: | ||
| build: | ||
| timeout-minutes: 60 | ||
| runs-on: ubuntu-22.04 | ||
| steps: | ||
| - uses: actions/checkout@v6 | ||
|
|
||
| - uses: actions/setup-node@v6 | ||
| with: | ||
| node-version: 22.x | ||
| cache: 'npm' | ||
|
|
||
| - name: Install wasm-pack | ||
| uses: jetli/[email protected] | ||
|
|
||
| - name: Install dependencies | ||
| run: npm ci | ||
|
|
||
| - name: Setup GOV.UK | ||
| run: npm run setup-govuk | ||
|
|
||
| - name: Install Playwright Browsers | ||
| run: npx playwright install --with-deps | ||
|
|
||
| - name: Run type-checker | ||
| run: npm run check | ||
|
|
||
| - name: Run Playwright tests | ||
| run: npm test | ||
|
|
||
| - name: Upload test results | ||
| run: npx github-actions-ctrf ctrf/ctrf-report.json | ||
| if: always() | ||
|
|
||
| - name: Upload test results for historical report | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: ctrf-report | ||
| path: ctrf/ctrf-report.json | ||
| if: always() | ||
|
|
||
| - name: Build svelte app | ||
| run: npm run build | ||
|
|
||
| - id: auth | ||
| name: Authenticate with Google Cloud | ||
| uses: google-github-actions/auth@v3 | ||
| with: | ||
| token_format: access_token | ||
| credentials_json: '${{ secrets.GCP_CREDENTIALS_PUSH }}' | ||
|
|
||
| - name: Login to Docker repository | ||
| uses: docker/login-action@v4 | ||
| with: | ||
| registry: ${{ env.IMAGE_LOCATION }}-docker.pkg.dev | ||
| username: oauth2accesstoken | ||
| password: ${{ steps.auth.outputs.access_token }} | ||
|
|
||
| - id: meta | ||
| name: Extract metadata | ||
| uses: docker/metadata-action@v6 | ||
| with: | ||
| images: ${{ env.IMAGE_LOCATION }}-docker.pkg.dev/${{ env.IMAGE_PROJECT }}/${{ env.IMAGE_REPOSITORY_ID }}/${{ env.IMAGE_NAME }} | ||
| tags: | | ||
| type=semver,pattern={{version}} | ||
| type=ref,event=branch,enable={{is_not_default_branch}} | ||
| type=ref,event=pr,enable={{is_not_default_branch}} | ||
| type=raw,value=latest,enable={{is_default_branch}} | ||
|
|
||
| - name: Build and push image | ||
| uses: docker/build-push-action@v7 | ||
| with: | ||
| context: . | ||
| tags: ${{ steps.meta.outputs.tags }} | ||
| labels: ${{ steps.meta.outputs.labels }} | ||
| push: true | ||
|
|
||
| deploy: | ||
| needs: build | ||
| uses: ./.github/workflows/deploy.yml | ||
| with: | ||
| environment: Dev | ||
| tag: ${{ needs.build.outputs.version }} | ||
| # only run deploy for CI runs on main | ||
| if: github.event_name != 'pull_request' | ||
| secrets: | ||
| GCP_CREDENTIALS_DEPLOY: ${{ secrets.GCP_CREDENTIALS_DEPLOY }} | ||
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 |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| name: Deploy | ||
| run-name: 'Deploy ${{ inputs.tag }} to ${{ inputs.environment }}' | ||
|
|
||
| on: | ||
| workflow_call: | ||
| inputs: | ||
| environment: | ||
| description: Environment | ||
| type: string | ||
| required: true | ||
|
|
||
| tag: | ||
| description: Docker image tag | ||
| type: string | ||
| required: true | ||
|
|
||
| secrets: | ||
| GCP_CREDENTIALS_DEPLOY: | ||
| required: true | ||
|
|
||
| workflow_dispatch: | ||
| inputs: | ||
| environment: | ||
| description: Environment | ||
| type: environment | ||
| required: true | ||
|
|
||
| tag: | ||
| description: Docker image tag | ||
| type: string | ||
| required: true | ||
| default: latest | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| env: | ||
| IMAGE_PROJECT: dft-rlg-atip-dev | ||
| IMAGE_LOCATION: europe-west1 | ||
| IMAGE_REPOSITORY_ID: docker | ||
| IMAGE_NAME: plan | ||
| SERVICE_LOCATION: europe-west1 | ||
| SERVICE_NAME: plan | ||
|
|
||
| jobs: | ||
|
|
||
| deploy: | ||
| runs-on: ubuntu-24.04 | ||
| environment: ${{ inputs.environment }} | ||
| steps: | ||
| - name: Authenticate with Google Cloud | ||
| uses: google-github-actions/auth@v3 | ||
| with: | ||
| credentials_json: '${{ secrets.GCP_CREDENTIALS_DEPLOY }}' | ||
|
|
||
| - name: Deploy image | ||
| uses: google-github-actions/deploy-cloudrun@v3 | ||
| with: | ||
| service: ${{ env.SERVICE_NAME }} | ||
| image: ${{ env.IMAGE_LOCATION }}-docker.pkg.dev/${{ env.IMAGE_PROJECT }}/${{ env.IMAGE_REPOSITORY_ID }}/${{ env.IMAGE_NAME }}:${{ inputs.tag }} | ||
| region: ${{ env.SERVICE_LOCATION }} |
This file was deleted.
Oops, something went wrong.
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 |
|---|---|---|
|
|
@@ -20,3 +20,7 @@ ctrf | |
|
|
||
| # playwright | ||
| test-results | ||
|
|
||
| # terraform | ||
| .terraform/ | ||
| /cloud/browse/tf-backend/terraform.tfstate* | ||
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 |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| FROM node:22-slim | ||
|
|
||
| ENV PORT=8080 | ||
|
|
||
| WORKDIR /usr/src/app | ||
| COPY backend . | ||
|
|
||
| RUN npm install --production | ||
|
|
||
| USER node | ||
|
|
||
| CMD [ "sh", "-c", "npm start" ] |
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 |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| # Cloud infrastructure | ||
|
|
||
| This service is hosted on [Google Cloud Platform](https://console.cloud.google.com/). | ||
|
|
||
| ## Prerequisites | ||
|
|
||
| 1. Install [Google Cloud CLI](https://cloud.google.com/sdk/docs/install) | ||
|
|
||
| ## Provisioning | ||
|
|
||
| To provision the cloud infrastructure: | ||
|
|
||
| 1. Provision the [Terraform backend](tf-backend/README.md) | ||
| 2. Provision the [Docker repository](docker-repository/README.md) | ||
| 3. Provision the [storage bucket](storage-bucket/README.md) | ||
| 4. Provision the [service](service/README.md) |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.