Skip to content

Commit 7ad8ca6

Browse files
authored
Use ESC secrets (#3041)
These changes migrate this repo's GitHub Actions Workflows to use ESC secrets instead of GitHub Secrets. The changes are largely mechanical: - Common configuration for all ESC actions within a workflow is added to the workflow's environment variables - Permissions are expanded as necessary for workflows that do not grant `id-token: write` permissions - `read-all` permissions are replaced with the union of all explicit read permissions and `id-token: write` - Default permissions are replaced with `write-all`, which is the equivalent of all explicit write permissions and `id-token: write` - Explicit permissions are modified to grant `id-token: write` - A step that fetches ESC secrets and populates environment variables is added to each step that reads secrets - Direct references to secrets within the job are replaced with references to the step's outputs All ESC actions are configured to fetch secrets from a shared ESC environment that contains secrets migrated from GitHub Actions. The ESC action performs its own OIDC exchange to obtain a Pulumi Access Token.
1 parent 9284425 commit 7ad8ca6

File tree

7 files changed

+60
-10
lines changed

7 files changed

+60
-10
lines changed

.github/workflows/build-and-test.yml

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
permissions: write-all # Equivalent to default permissions plus id-token: write
12
name: Build and Test
23

34
on:
@@ -11,6 +12,11 @@ env:
1112
# Note this needs to match the shard input to the test matrix below as well as pattern in exclude.
1213
# see jobs.test.strategy.matrix.{shard,exclude}
1314
TOTAL_SHARDS: 15
15+
ESC_ACTION_OIDC_AUTH: true
16+
ESC_ACTION_OIDC_ORGANIZATION: pulumi
17+
ESC_ACTION_OIDC_REQUESTED_TOKEN_TYPE: urn:pulumi:token-type:access_token:organization
18+
ESC_ACTION_ENVIRONMENT: imports/github-secrets
19+
ESC_ACTION_EXPORT_ENVIRONMENT_VARIABLES: false
1420

1521
jobs:
1622
test:
@@ -90,6 +96,9 @@ jobs:
9096
shard: 14
9197
runs-on: ${{ matrix.platform }}
9298
steps:
99+
- name: Fetch secrets from ESC
100+
id: esc-secrets
101+
uses: pulumi/esc-action@v1
93102
- name: Install terraform
94103
uses: hashicorp/setup-terraform@v3
95104
with:
@@ -129,7 +138,7 @@ jobs:
129138
if: ${{ env.CODECOV_TOKEN != '' }}
130139
uses: codecov/codecov-action@v4
131140
env:
132-
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
141+
CODECOV_TOKEN: ${{ steps.esc-secrets.outputs.CODECOV_TOKEN }}
133142
lint:
134143
runs-on: ubuntu-latest
135144
steps:
@@ -150,8 +159,7 @@ jobs:
150159
run: make lint
151160
sentinel:
152161
name: sentinel
153-
if: github.event_name == 'repository_dispatch' ||
154-
github.event.pull_request.head.repo.full_name == github.repository
162+
if: github.event_name == 'repository_dispatch' || github.event.pull_request.head.repo.full_name == github.repository
155163
permissions:
156164
statuses: write
157165
needs:

.github/workflows/ci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
permissions: write-all # Equivalent to default permissions plus id-token: write
12
env:
23
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
34

.github/workflows/master.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
permissions: write-all # Equivalent to default permissions plus id-token: write
12
name: Master and Tag Builds
23

34
on:
@@ -11,7 +12,11 @@ on:
1112
- 'README.md'
1213

1314
env:
14-
GITHUB_TOKEN: ${{ secrets.PULUMI_BOT_TOKEN }}
15+
ESC_ACTION_OIDC_AUTH: true
16+
ESC_ACTION_OIDC_ORGANIZATION: pulumi
17+
ESC_ACTION_OIDC_REQUESTED_TOKEN_TYPE: urn:pulumi:token-type:access_token:organization
18+
ESC_ACTION_ENVIRONMENT: imports/github-secrets
19+
ESC_ACTION_EXPORT_ENVIRONMENT_VARIABLES: GITHUB_TOKEN=PULUMI_BOT_TOKEN
1520

1621
jobs:
1722
build:

.github/workflows/update-providers-auto.yml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
permissions: write-all # Equivalent to default permissions plus id-token: write
12
name: Update Providers with new bridge version upon release
23
on:
34
push:
@@ -8,6 +9,11 @@ on:
89

910
env:
1011
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
12+
ESC_ACTION_OIDC_AUTH: true
13+
ESC_ACTION_OIDC_ORGANIZATION: pulumi
14+
ESC_ACTION_OIDC_REQUESTED_TOKEN_TYPE: urn:pulumi:token-type:access_token:organization
15+
ESC_ACTION_ENVIRONMENT: imports/github-secrets
16+
ESC_ACTION_EXPORT_ENVIRONMENT_VARIABLES: false
1117

1218
jobs:
1319
generate-providers-list:
@@ -22,6 +28,9 @@ jobs:
2228
runs-on: ubuntu-latest
2329
name: Upgrade ${{ matrix.provider }} to pulumi-terraform-bridge to the latest version automatically
2430
steps:
31+
- name: Fetch secrets from ESC
32+
id: esc-secrets
33+
uses: pulumi/esc-action@v1
2534
- name: Check for provider hotfixes
2635
id: hotfix_check
2736
run: |
@@ -42,7 +51,7 @@ jobs:
4251
- name: Trigger upgrade
4352
uses: peter-evans/repository-dispatch@v3
4453
with:
45-
token: ${{ secrets.PULUMI_BOT_TOKEN }}
54+
token: ${{ steps.esc-secrets.outputs.PULUMI_BOT_TOKEN }}
4655
repository: pulumi/pulumi-${{ matrix.provider }}
4756
event-type: upgrade-bridge
4857
# Not specifying target-bridge-version in the payload will make it upgrade to the latest.

.github/workflows/update-providers-test.yml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
permissions: write-all # Equivalent to default permissions plus id-token: write
2+
env:
3+
ESC_ACTION_OIDC_AUTH: true
4+
ESC_ACTION_OIDC_ORGANIZATION: pulumi
5+
ESC_ACTION_OIDC_REQUESTED_TOKEN_TYPE: urn:pulumi:token-type:access_token:organization
6+
ESC_ACTION_ENVIRONMENT: imports/github-secrets
7+
ESC_ACTION_EXPORT_ENVIRONMENT_VARIABLES: false
18
name: Test the bridge by previewing provider bridge upgrades
29

310
on:
@@ -42,10 +49,13 @@ jobs:
4249
runs-on: ubuntu-latest
4350
name: Test upgrading ${{ matrix.provider }} to pulumi-terraform-bridge ${{ github.sha }}
4451
steps:
52+
- name: Fetch secrets from ESC
53+
id: esc-secrets
54+
uses: pulumi/esc-action@v1
4555
- name: Trigger upgrade
4656
uses: peter-evans/repository-dispatch@v3
4757
with:
48-
token: ${{ secrets.PULUMI_BOT_TOKEN }}
58+
token: ${{ steps.esc-secrets.outputs.PULUMI_BOT_TOKEN }}
4959
repository: pulumi/pulumi-${{ matrix.provider }}
5060
event-type: upgrade-bridge-test
5161
client-payload: |-

.github/workflows/update-providers.yml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
permissions: write-all # Equivalent to default permissions plus id-token: write
12
name: Update Providers with new bridge version
23
on:
34
workflow_dispatch:
@@ -13,6 +14,11 @@ on:
1314

1415
env:
1516
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
17+
ESC_ACTION_OIDC_AUTH: true
18+
ESC_ACTION_OIDC_ORGANIZATION: pulumi
19+
ESC_ACTION_OIDC_REQUESTED_TOKEN_TYPE: urn:pulumi:token-type:access_token:organization
20+
ESC_ACTION_ENVIRONMENT: imports/github-secrets
21+
ESC_ACTION_EXPORT_ENVIRONMENT_VARIABLES: false
1622

1723
jobs:
1824

@@ -28,10 +34,13 @@ jobs:
2834
runs-on: ubuntu-latest
2935
name: Upgrade ${{ matrix.provider }} to pulumi-terraform-bridge ${{ github.event.inputs.bridgeVersion }}
3036
steps:
37+
- name: Fetch secrets from ESC
38+
id: esc-secrets
39+
uses: pulumi/esc-action@v1
3140
- name: Trigger upgrade
3241
uses: peter-evans/repository-dispatch@v3
3342
with:
34-
token: ${{ secrets.PULUMI_BOT_TOKEN }}
43+
token: ${{ steps.esc-secrets.outputs.PULUMI_BOT_TOKEN }}
3544
repository: pulumi/pulumi-${{ matrix.provider }}
3645
event-type: upgrade-bridge
3746
client-payload: |-

.github/workflows/weekly-pulumi-update.yml

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
1+
permissions: write-all # Equivalent to default permissions plus id-token: write
12
name: weekly-pulumi-update
23
on:
34
schedule:
45
- cron: 35 12 * * 4
56
workflow_dispatch: {}
67
env:
7-
GITHUB_TOKEN: ${{ secrets.PULUMI_BOT_TOKEN }}
8+
ESC_ACTION_OIDC_AUTH: true
9+
ESC_ACTION_OIDC_ORGANIZATION: pulumi
10+
ESC_ACTION_OIDC_REQUESTED_TOKEN_TYPE: urn:pulumi:token-type:access_token:organization
11+
ESC_ACTION_ENVIRONMENT: imports/github-secrets
12+
ESC_ACTION_EXPORT_ENVIRONMENT_VARIABLES: GITHUB_TOKEN=PULUMI_BOT_TOKEN
813
jobs:
914
weekly-pulumi-update:
1015
runs-on: ubuntu-latest
@@ -14,6 +19,9 @@ jobs:
1419
goversion:
1520
- 1.23.x
1621
steps:
22+
- name: Fetch secrets from ESC
23+
id: esc-secrets
24+
uses: pulumi/esc-action@v1
1725
- name: Checkout Repo
1826
uses: actions/checkout@v3
1927
with:
@@ -73,9 +81,9 @@ jobs:
7381
source_branch: update-pulumi/${{ github.run_id }}-${{ github.run_number }}
7482
destination_branch: master
7583
pr_title: Automated Pulumi/Pulumi upgrade
76-
github_token: ${{ secrets.PULUMI_BOT_TOKEN }}
84+
github_token: ${{ steps.esc-secrets.outputs.PULUMI_BOT_TOKEN }}
7785
env:
78-
GITHUB_TOKEN: ${{ secrets.PULUMI_BOT_TOKEN }}
86+
GITHUB_TOKEN: ${{ steps.esc-secrets.outputs.PULUMI_BOT_TOKEN }}
7987
- name: "Set PR to auto-merge"
8088
if: steps.gomod.outputs.changes != 0
8189
run: "gh pr merge --auto --squash ${{ steps.create-pr.outputs.pr_url }}"

0 commit comments

Comments
 (0)