Skip to content

Commit 1688cc9

Browse files
authored
Improve infisical workflow (#2206)
1 parent b781ad4 commit 1688cc9

4 files changed

Lines changed: 29 additions & 20 deletions

File tree

.github/actions/deploy-setup/action.yml

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,38 +4,38 @@ inputs:
44
environment:
55
description: "Target environment for deployment, e.g. staging"
66
required: true
7-
infisical_client_id:
8-
description: "Infisical client ID for accessing secrets"
9-
required: true
10-
infisical_client_secret:
11-
description: "Infisical client secret for accessing secrets"
12-
required: true
137
install_gcloud:
148
description: "Whether to install the gcloud CLI (needed for gsutil/docker auth)"
159
required: false
1610
default: "false"
11+
infisical_machine_identity_id:
12+
description: "Infisical machine identity ID for accessing secrets"
13+
required: true
1714

1815
runs:
1916
using: "composite"
2017
steps:
21-
- uses: Infisical/secrets-action@v1.0.9
18+
- name: Pull infisical secrets into temporary file
19+
uses: Infisical/secrets-action@v1.0.15
2220
with:
23-
client-id: ${{ inputs.infisical_client_id }}
24-
client-secret: ${{ inputs.infisical_client_secret }}
25-
env-slug: ${{ inputs.environment }}
21+
method: "oidc"
22+
identity-id: ${{ inputs.infisical_machine_identity_id }}
2623
project-slug: "infra-deployment"
24+
env-slug: ${{ inputs.environment }}
2725
export-type: "file"
2826
file-output-path: "/.env.infisical"
2927

30-
- name: Load Environment Variables
28+
- name: Transform infisical secrets into make include file, load a few as environment variables
3129
id: load-env
30+
env:
31+
ENVIRONMENT: ${{ inputs.environment }}
3232
run: |
33-
echo ${{ inputs.environment }} > .last_used_env
34-
cat .env.infisical | sed "s/='\(.*\)'$/=\1/g" > .env.${{ inputs.environment }}
33+
echo "${ENVIRONMENT}" > .last_used_env
34+
cat .env.infisical | sed "s/='\(.*\)'$/=\1/g" > ".env.${ENVIRONMENT}"
3535
3636
# Load environment variables from .env
3737
set -a
38-
. .env.${{ inputs.environment }}
38+
. ".env.${ENVIRONMENT}"
3939
set +a
4040
4141
echo "GCP_REGION=${GCP_REGION}" >> $GITHUB_ENV
@@ -44,6 +44,15 @@ runs:
4444
echo "GH_WORKLOAD_IDENTITY_PROVIDER=${GH_WORKLOAD_IDENTITY_PROVIDER}" >> $GITHUB_ENV
4545
shell: bash
4646

47+
- name: Load environment variables from Infisical
48+
uses: Infisical/secrets-action@v1.0.15
49+
with:
50+
method: "oidc"
51+
identity-id: ${{ inputs.infisical_machine_identity_id }}
52+
project-slug: "infra-deployment-env"
53+
env-slug: ${{ inputs.environment }}
54+
export-type: "env"
55+
4756
- name: Setup Service Account
4857
uses: google-github-actions/auth@v2
4958
with:

.github/workflows/build-and-upload-job.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ jobs:
3131
deploy:
3232
name: Build and upload job to the ${{ inputs.environment }} environment
3333
runs-on: ci-builder
34+
environment: ${{ inputs.environment }}
3435
permissions:
3536
contents: read
3637
id-token: write
@@ -45,9 +46,8 @@ jobs:
4546
uses: ./.github/actions/deploy-setup
4647
with:
4748
environment: ${{ inputs.environment }}
48-
infisical_client_id: ${{ secrets.INFISICAL_CLIENT_ID }}
49-
infisical_client_secret: ${{ secrets.INFISICAL_CLIENT_SECRET }}
5049
install_gcloud: "true"
50+
infisical_machine_identity_id: ${{ vars.INFISICAL_MACHINE_IDENTITY_ID }}
5151

5252
- name: Set up Docker
5353
env:

.github/workflows/deploy-infra.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ jobs:
2929
deploy:
3030
name: Deploy Infra to the ${{ inputs.environment }} environment
3131
runs-on: ubuntu-22.04
32+
environment: ${{ inputs.environment }}
3233
permissions:
3334
contents: read
3435
id-token: write
@@ -43,9 +44,8 @@ jobs:
4344
uses: ./.github/actions/deploy-setup
4445
with:
4546
environment: ${{ inputs.environment }}
46-
infisical_client_id: ${{ secrets.INFISICAL_CLIENT_ID }}
47-
infisical_client_secret: ${{ secrets.INFISICAL_CLIENT_SECRET }}
4847
install_gcloud: "true"
48+
infisical_machine_identity_id: ${{ vars.INFISICAL_MACHINE_IDENTITY_ID }}
4949

5050
- name: Run Terraform state migrations
5151
if: inputs.plan_only == 'false'

.github/workflows/deploy-job.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ jobs:
3232
deploy:
3333
name: Deploy job to the ${{ inputs.environment }} environment
3434
runs-on: ubuntu-22.04
35+
environment: ${{ inputs.environment }}
3536
permissions:
3637
contents: read
3738
id-token: write
@@ -46,8 +47,7 @@ jobs:
4647
uses: ./.github/actions/deploy-setup
4748
with:
4849
environment: ${{ inputs.environment }}
49-
infisical_client_id: ${{ secrets.INFISICAL_CLIENT_ID }}
50-
infisical_client_secret: ${{ secrets.INFISICAL_CLIENT_SECRET }}
50+
infisical_machine_identity_id: ${{ vars.INFISICAL_MACHINE_IDENTITY_ID }}
5151

5252
- name: Run Terraform state migrations
5353
if: inputs.plan_only == 'false'

0 commit comments

Comments
 (0)