-
Notifications
You must be signed in to change notification settings - Fork 0
89 lines (84 loc) · 2.85 KB
/
gcp_build.yml
File metadata and controls
89 lines (84 loc) · 2.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
name: Build Evaluation Function to GCP
on:
workflow_call:
inputs:
environment:
type: string
description: "The environment to deploy to"
required: false
region:
type: string
description: "The AWS region to deploy to"
default: "europe-west2"
required: false
function-name:
type: string
description: "The name of the Lambda function to deploy"
required: true
build-file:
type: string
description: "The path to the Dockerfile to build"
required: false
default: "Dockerfile"
build-context:
type: string
description: "The context to use for the Docker build"
required: false
default: "."
build-target:
type: string
description: "The target stage of the image to build"
required: false
build-args:
type: string
description: "The build arguments to pass to the Docker build"
required: false
build-push:
type: boolean
description: "Whether to push the image to the registry"
required: false
default: true
build-platforms:
type: string
description: "The platforms to build the image for"
required: false
secrets:
function-admin-api-key:
description: "The API key for the Lambda Feedback function admin API"
required: false
gcp_credentials:
description: "The JSON key for deploying to GCP"
required: true
outputs:
registry:
description: "The registry where the image was pushed"
value: ${{ jobs.build.outputs.registry }}
jobs:
build:
name: Build GCP (${{ inputs.environment }})
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
id-token: write
outputs:
registry: europe-west2-docker.pkg.dev/wolfram-evaluation-functions/${{ inputs.environment == 'staging' && 'evaluation-function-staging' || 'evaluation-function' }}/${{inputs.function-name}}:latest
steps:
- uses: 'actions/checkout@v4'
- id: 'auth'
uses: 'google-github-actions/auth@v3'
with:
credentials_json: '${{ secrets.gcp_credentials }}'
- name: Set up Google Cloud SDK
uses: google-github-actions/setup-gcloud@v1
with:
project_id: wolfram-evaluation-functions
- name: Configure Docker to use gcloud as a credential helper
run: |
gcloud auth configure-docker europe-west2-docker.pkg.dev
- name: Build and Push Docker image
id: 'build-push'
run: |
IMAGE_URI="europe-west2-docker.pkg.dev/wolfram-evaluation-functions/${{ inputs.environment == 'staging' && 'evaluation-function-staging' || 'evaluation-function' }}/${{inputs.function-name}}:latest"
docker build -t "$IMAGE_URI" .
docker push "$IMAGE_URI"