|
11 | 11 | default: "false" |
12 | 12 |
|
13 | 13 | jobs: |
14 | | - info: |
| 14 | + deploy: |
15 | 15 | if: "!contains(github.event.head_commit.message, 'skipci')" |
16 | | - runs-on: ubuntu-latest |
17 | | - |
18 | | - timeout-minutes: 5 |
19 | | - |
20 | | - permissions: |
21 | | - contents: read |
22 | | - |
23 | | - outputs: |
24 | | - branch_tag_kebab: ${{ steps.get-deployment-info.outputs.branch_tag_kebab }} |
25 | | - branch_tag_screaming: ${{ steps.get-deployment-info.outputs.branch_tag_screaming}} |
26 | | - image_latest_artifact: ${{ steps.get-deployment-info.outputs.image_latest_artifact}} |
27 | | - image_latest_tag: ${{ steps.get-deployment-info.outputs.image_latest_tag }} |
28 | | - image_version_artifact: ${{ steps.get-deployment-info.outputs.image_version_artifact}} |
29 | | - image_version_tag: ${{ steps.get-deployment-info.outputs.image_version_tag }} |
30 | | - short_sha: ${{ steps.get-deployment-info.outputs.short_sha }} |
31 | | - gcp_project_name: ${{ steps.get-deployment-info.outputs.gcp_project_name}} |
32 | | - gcp_project_number: ${{ steps.get-deployment-info.outputs.gcp_project_number}} |
33 | | - gcp_region: ${{ steps.get-deployment-info.outputs.gcp_region}} |
34 | | - gcp_resource_affix: ${{ steps.get-deployment-info.outputs.gcp_resource_affix}} |
35 | | - gcp_service_name: ${{ steps.get-deployment-info.outputs.gcp_service_name}} |
36 | | - version: ${{ steps.get-deployment-info.outputs.version }} |
37 | | - revision_tag: ${{ steps.get-deployment-info.outputs.revision_tag }} |
38 | | - revision_tag_slug: ${{ steps.get-deployment-info.outputs.revision_tag_slug }} |
39 | | - |
40 | | - steps: |
41 | | - - name: Checkout |
42 | | - uses: actions/checkout@v4 |
43 | | - |
44 | | - - name: Install poetry |
45 | | - uses: snok/install-poetry@v1 |
46 | | - |
47 | | - - name: Get deployment info |
48 | | - id: get-deployment-info |
49 | | - |
50 | | - with: |
51 | | - gcp_project_name: octue-sdk-python |
52 | | - gcp_project_number: 437801218871 |
53 | | - gcp_region: europe-west1 |
54 | | - gcp_resource_affix: octue |
55 | | - gcp_service_name: example-service-cloud-run |
56 | | - |
57 | | - build: |
58 | | - runs-on: ubuntu-latest |
59 | | - timeout-minutes: 60 |
60 | | - needs: info |
| 16 | + uses: octue/workflows/.github/workflows/deploy-cloud-run-service.yml@main |
61 | 17 | permissions: |
62 | 18 | id-token: write |
63 | 19 | contents: read |
64 | | - |
65 | | - steps: |
66 | | - - name: Checkout |
67 | | - uses: actions/checkout@v4 |
68 | | - |
69 | | - - name: Set up QEMU |
70 | | - uses: docker/setup-qemu-action@v2 |
71 | | - |
72 | | - - name: Set up Docker Buildx |
73 | | - uses: docker/setup-buildx-action@v2 |
74 | | - |
75 | | - - name: Authenticate with GCP Workload Identity |
76 | | - id: auth |
77 | | - uses: google-github-actions/auth@v2 |
78 | | - with: |
79 | | - # NOTE: If setting create_credentials_file=true, .dockerignore file must include `gha-creds-*.json` to avoid baking these credentials into build |
80 | | - create_credentials_file: true |
81 | | - workload_identity_provider: projects/${{ needs.info.outputs.gcp_project_number }}/locations/global/workloadIdentityPools/github-actions-pool/providers/github-actions-provider |
82 | | - service_account: github-actions@${{ needs.info.outputs.gcp_project_name }}.iam.gserviceaccount.com |
83 | | - |
84 | | - - name: Setup gcloud |
85 | | - uses: "google-github-actions/setup-gcloud@v2" |
86 | | - |
87 | | - - name: Configure Docker for GCP |
88 | | - run: gcloud auth configure-docker ${{ needs.info.outputs.gcp_region }}-docker.pkg.dev |
89 | | - |
90 | | - - name: Setup tmate session [DEBUG] |
91 | | - if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.debug_enabled == 'true'}} |
92 | | - uses: mxschmitt/action-tmate@v3 |
93 | | - |
94 | | - - name: Get default Octue Cloud Run Dockerfile |
95 | | - run: wget https://raw.githubusercontent.com/octue/octue-sdk-python/main/octue/cloud/deployment/google/cloud_run/Dockerfile |
96 | | - |
97 | | - - name: Build and push container with latest and version tags |
98 | | - # Note: We don't push containers with shas because we'd end up with terabytes in storage (an image for every commit) |
99 | | - uses: docker/build-push-action@v2 |
100 | | - with: |
101 | | - context: . |
102 | | - platforms: linux/amd64 |
103 | | - file: ./Dockerfile |
104 | | - push: true |
105 | | - cache-from: type=gha |
106 | | - cache-to: type=gha,mode=max |
107 | | - tags: | |
108 | | - ${{ needs.info.outputs.image_version_artifact}} |
109 | | - ${{ needs.info.outputs.image_latest_artifact}} |
110 | | -
|
111 | | - - name: Deploy to Cloud Run service |
112 | | - id: deploy-service |
113 | | - uses: google-github-actions/deploy-cloudrun@v2 |
114 | | - with: |
115 | | - env_vars: | |
116 | | - OCTUE_SERVICE_NAMESPACE=${{ needs.info.outputs.gcp_resource_affix }} |
117 | | - OCTUE_SERVICE_NAME=${{ needs.info.outputs.gcp_service_name }} |
118 | | - OCTUE_SERVICE_REVISION_TAG=${{ needs.info.outputs.revision_tag }} |
119 | | - COMPUTE_PROVIDER=GOOGLE_CLOUD_RUN |
120 | | - service: ${{ needs.info.outputs.gcp_resource_affix }}-${{ needs.info.outputs.gcp_service_name }} |
121 | | - image: ${{ needs.info.outputs.image_version_artifact }} |
122 | | - region: ${{ needs.info.outputs.gcp_region }} |
123 | | - tag: v${{ needs.info.outputs.revision_tag_slug }} |
124 | | - flags: "--allow-unauthenticated" |
125 | | - |
126 | | - - name: Show deployed service URL |
127 | | - run: echo "${{ steps.deploy-service.outputs.url }}" |
128 | | - |
129 | | - - name: Create service revision push subscription |
130 | | - |
131 | | - with: |
132 | | - project_name: ${{ needs.info.outputs.gcp_project_name }} |
133 | | - service_namespace: ${{ needs.info.outputs.gcp_resource_affix }} |
134 | | - service_name: ${{ needs.info.outputs.gcp_service_name }} |
135 | | - service_revision_tag: ${{ needs.info.outputs.revision_tag }} |
136 | | - push_endpoint: ${{ steps.deploy-service.outputs.url }} |
| 20 | + with: |
| 21 | + gcp_project_name: octue-sdk-python |
| 22 | + gcp_project_number: 437801218871 |
| 23 | + gcp_region: europe-west1 |
| 24 | + gcp_resource_affix: octue |
| 25 | + gcp_service_name: example-service-cloud-run |
| 26 | + cloud_run_flags: "--ingress=all --allow-unauthenticated" |
0 commit comments