-
Notifications
You must be signed in to change notification settings - Fork 370
105 lines (89 loc) · 3.09 KB
/
Copy pathbuild-and-upload-images.yml
File metadata and controls
105 lines (89 loc) · 3.09 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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
name: Build and upload images
on:
push:
branches:
- main
workflow_dispatch:
permissions:
contents: read
id-token: write
jobs:
build-images:
name: Build and upload images to the ${{ matrix.environment }} environment
runs-on: ci-builder
strategy:
fail-fast: false
matrix:
environment:
- staging
- foxtrot
- juliett
- tango
environment: ${{ matrix.environment }}
concurrency:
group: build-images-${{ matrix.environment }}
cancel-in-progress: false
permissions:
contents: read
id-token: write
steps:
- name: Checkout repository
uses: actions/checkout@v5
with:
ref: ${{ github.sha }}
persist-credentials: false
- name: Pull deployment secrets into temporary file
uses: Infisical/secrets-action@v1.0.16
with:
method: "oidc"
identity-id: ${{ vars.INFISICAL_MACHINE_IDENTITY_ID }}
project-slug: "infra-deployment"
env-slug: ${{ matrix.environment }}
export-type: "file"
file-output-path: "/.env.infisical"
- name: Load deployment environment
env:
ENVIRONMENT: ${{ matrix.environment }}
run: |
echo "${ENVIRONMENT}" > .last_used_env
cat .env.infisical | sed "s/='\(.*\)'$/=\1/g" > ".env.${ENVIRONMENT}"
set -a
. ".env.${ENVIRONMENT}"
set +a
echo "GCP_REGION=${GCP_REGION}" >> "$GITHUB_ENV"
echo "GCP_PROJECT_ID=${GCP_PROJECT_ID}" >> "$GITHUB_ENV"
echo "GH_WORKLOAD_IDENTITY_PROVIDER=${GH_WORKLOAD_IDENTITY_PROVIDER}" >> "$GITHUB_ENV"
- name: Load runtime environment
uses: Infisical/secrets-action@v1.0.16
with:
method: "oidc"
identity-id: ${{ vars.INFISICAL_MACHINE_IDENTITY_ID }}
project-slug: "infra-deployment-env"
env-slug: ${{ matrix.environment }}
export-type: "env"
- name: Setup Service Account
uses: google-github-actions/auth@v3
with:
project_id: ${{ env.GCP_PROJECT_ID }}
workload_identity_provider: ${{ env.GH_WORKLOAD_IDENTITY_PROVIDER }}
- name: Set up Cloud SDK
uses: google-github-actions/setup-gcloud@v3
- name: Set up Docker
env:
GCP_REGION: ${{ env.GCP_REGION }}
run: |
gcloud auth configure-docker "${GCP_REGION}-docker.pkg.dev" --quiet
ACCESS_TOKEN="$(gcloud auth print-access-token)"
DOCKER_AUTH_BASE64="$(echo -n "{\"username\":\"oauth2accesstoken\",\"password\":\"$ACCESS_TOKEN\"}" | base64 -w 0)"
echo "::add-mask::$DOCKER_AUTH_BASE64"
echo "DOCKER_AUTH_BASE64=${DOCKER_AUTH_BASE64}" >> "$GITHUB_ENV"
- name: Build and upload images
env:
AUTO_CONFIRM_DEPLOY: true
ENVD_UPLOAD_MODE: versioned
run: make build-and-upload
- name: Promote envd in staging
if: ${{ matrix.environment == 'staging' }}
env:
ENVD_COMMIT_SHA: ${{ github.sha }}
run: make -C packages/envd promote