Skip to content

Commit 4ef1170

Browse files
authored
Iterate on the java update job: move worklow to repos (#1616)
Calling upgrade-provider from ci-mgmt does not have the right GitHub permissions to edit the repository being automated. It works allright from within the repository as in: pulumi/pulumi-tls#810 Switching to this pattern where ci-mgmt simply dispatches jobs to subordinate repositories. This might need a few more iterations to get quite right.
1 parent fcb8220 commit 4ef1170

File tree

7 files changed

+415
-30
lines changed

7 files changed

+415
-30
lines changed

.github/workflows/update-java.yml

Lines changed: 43 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ on:
1010
description: Desired version of pulumi/pulumi-java to ugprade to.
1111
required: true
1212
type: string
13+
provider:
14+
description: |
15+
A single provider, such as 'aws', to update. If 'all' all providers are updated.
16+
required: false
17+
default: all
1318

1419
env:
1520
ESC_ACTION_OIDC_AUTH: true
@@ -28,7 +33,19 @@ jobs:
2833
uses: pulumi/esc-action@cf5b30703ffd5ad60cc3a880c09b3a9592b9372d # v1
2934
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
3035
- id: get-providers
31-
run: echo "providers=$(jq . providers.json --compact-output)" >> "$GITHUB_OUTPUT"
36+
shell: bash
37+
env:
38+
PROVIDER: ${{inputs.provider}}
39+
run: |
40+
case "$PROVIDER" in
41+
all)
42+
echo "providers=$(jq . providers.json --compact-output)" >> "$GITHUB_OUTPUT"
43+
;;
44+
45+
*)
46+
echo "providers=[\"${PROVIDER}\"]" >> "$GITHUB_OUTPUT"
47+
;;
48+
esac
3249
working-directory: provider-ci
3350
outputs:
3451
providers: ${{ steps.get-providers.outputs.providers }}
@@ -49,37 +66,33 @@ jobs:
4966
- name: Fetch secrets from ESC
5067
id: esc-secrets
5168
uses: pulumi/esc-action@cf5b30703ffd5ad60cc3a880c09b3a9592b9372d # v1
52-
53-
- name: Checkout provider sources
54-
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
55-
with:
56-
repository: pulumi/pulumi-${matrix.provider}
57-
path: provider
58-
59-
- name: Install upgrade-provider
60-
run: go install github.com/pulumi/upgrade-provider@main
61-
shell: bash
62-
63-
- name: Install pulumictl
64-
uses: jaxxstorm/[email protected]
65-
with:
66-
repo: pulumi/pulumictl
67-
68-
- name: Install Pulumi CLI
69-
uses: pulumi/actions@df5a93ad715135263c732ba288301bd044c383c0 # v6
70-
71-
- name: "Set up git identity: name"
72-
run: git config --global user.name '${{ github.actor }}'
73-
shell: bash
74-
75-
- name: Upgrade Java
69+
- name: Format inputs
7670
shell: bash
71+
id: format-inputs
7772
env:
78-
P: pulumi/pulumi-${{matrix.provider}}
79-
V: ${{inputs.pulumi-java-version}}
73+
V: ${{ inputs.pulumi-java-version }}
8074
run: |
81-
cd provider
82-
upgrade-provider "$P" --kind=java --java-version="$V"
83-
75+
INPUTS_JSON=$(jq -n --arg v "$V" '{version: $v}')
76+
echo "json=$INPUTS_JSON" >> "$GITHUB_OUTPUT"
77+
- name: pulumi-${{ matrix.provider }} main
78+
id: upgrade-on-main
79+
uses: benc-uk/workflow-dispatch@e2e5e9a103e331dad343f381a29e654aea3cf8fc # v1.2.4
80+
continue-on-error: true
81+
with:
82+
workflow: upgrade-java.yml
83+
token: ${{ steps.esc-secrets.outputs.PULUMI_BOT_TOKEN }}
84+
repo: pulumi/pulumi-${{ matrix.provider }}
85+
inputs: ${{ steps.format-inputs.outputs.json }}
86+
ref: main
87+
- name: pulumi-${{ matrix.provider }} master
88+
id: upgrade-on-master
89+
if: steps.upgrade-on-main.outcome == 'failure'
90+
uses: benc-uk/workflow-dispatch@e2e5e9a103e331dad343f381a29e654aea3cf8fc # v1.2.4
91+
with:
92+
workflow: upgrade-java.yml
93+
token: ${{ steps.esc-secrets.outputs.PULUMI_BOT_TOKEN }}
94+
repo: pulumi/pulumi-${{ matrix.provider }}
95+
ref: master
96+
inputs: ${{ steps.format-inputs.outputs.json }}
8497
- name: Sleep to prevent hitting secondary rate limits
8598
run: sleep 1
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# WARNING: This file is autogenerated - changes will be overwritten when regenerated by https://github.com/pulumi/ci-mgmt
2+
3+
name: Upgrade Java
4+
on:
5+
workflow_dispatch:
6+
inputs:
7+
version:
8+
description: |
9+
The version of pulumi/pulumi-java to upgrade to, without the 'v' prefix
10+
required: true
11+
type: string
12+
upgradeProviderVersion:
13+
description: |
14+
Version of upgrade-provider to use. This must be a valid git reference in the pulumi/upgrade-provider repo. Defaults to "main"
15+
16+
See https://go.dev/ref/mod#versions for valid versions. E.g. "v0.1.0", "main", "da25dec".
17+
default: main
18+
type: string
19+
20+
permissions:
21+
contents: write
22+
issues: write
23+
pull-requests: write
24+
25+
env:
26+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
27+
28+
jobs:
29+
upgrade_java:
30+
name: upgrade-java
31+
runs-on: ubuntu-latest
32+
steps:
33+
34+
- name: Checkout Repo
35+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
36+
with:
37+
# Persist credentials so upgrade-provider can push a new branch.
38+
persist-credentials: true
39+
40+
- name: Setup tools
41+
uses: ./.github/actions/setup-tools
42+
with:
43+
tools: pulumictl, pulumicli, go
44+
45+
- name: Install upgrade-provider
46+
run: go install github.com/pulumi/upgrade-provider@${{ inputs.upgradeProviderVersion || 'main' }}
47+
shell: bash
48+
49+
- name: "Set up git identity"
50+
run: |
51+
git config --global user.name '[email protected]'
52+
git config --global user.email '[email protected]'
53+
shell: bash
54+
55+
- name: Upgrade Java
56+
shell: bash
57+
id: upgrade_provider
58+
env:
59+
V: ${{inputs.version}}
60+
REPO: ${{github.repository}}
61+
run: |
62+
upgrade-provider "$REPO" --kind=java --java-version="$V"
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# WARNING: This file is autogenerated - changes will be overwritten when regenerated by https://github.com/pulumi/ci-mgmt
2+
3+
name: Upgrade Java
4+
on:
5+
workflow_dispatch:
6+
inputs:
7+
version:
8+
description: |
9+
The version of pulumi/pulumi-java to upgrade to, without the 'v' prefix
10+
required: true
11+
type: string
12+
upgradeProviderVersion:
13+
description: |
14+
Version of upgrade-provider to use. This must be a valid git reference in the pulumi/upgrade-provider repo. Defaults to "main"
15+
16+
See https://go.dev/ref/mod#versions for valid versions. E.g. "v0.1.0", "main", "da25dec".
17+
default: main
18+
type: string
19+
20+
permissions:
21+
contents: write
22+
issues: write
23+
pull-requests: write
24+
25+
env:
26+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
27+
28+
jobs:
29+
upgrade_java:
30+
name: upgrade-java
31+
runs-on: ubuntu-latest
32+
steps:
33+
34+
- name: Checkout Repo
35+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
36+
with:
37+
# Persist credentials so upgrade-provider can push a new branch.
38+
persist-credentials: true
39+
40+
- name: Setup tools
41+
uses: ./.github/actions/setup-tools
42+
with:
43+
tools: pulumictl, pulumicli, go
44+
45+
- name: Install upgrade-provider
46+
run: go install github.com/pulumi/upgrade-provider@${{ inputs.upgradeProviderVersion || 'main' }}
47+
shell: bash
48+
49+
- name: "Set up git identity"
50+
run: |
51+
git config --global user.name '[email protected]'
52+
git config --global user.email '[email protected]'
53+
shell: bash
54+
55+
- name: Upgrade Java
56+
shell: bash
57+
id: upgrade_provider
58+
env:
59+
V: ${{inputs.version}}
60+
REPO: ${{github.repository}}
61+
run: |
62+
upgrade-provider "$REPO" --kind=java --java-version="$V"
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# WARNING: This file is autogenerated - changes will be overwritten when regenerated by https://github.com/pulumi/ci-mgmt
2+
3+
name: Upgrade Java
4+
on:
5+
workflow_dispatch:
6+
inputs:
7+
version:
8+
description: |
9+
The version of pulumi/pulumi-java to upgrade to, without the 'v' prefix
10+
required: true
11+
type: string
12+
upgradeProviderVersion:
13+
description: |
14+
Version of upgrade-provider to use. This must be a valid git reference in the pulumi/upgrade-provider repo. Defaults to "main"
15+
16+
See https://go.dev/ref/mod#versions for valid versions. E.g. "v0.1.0", "main", "da25dec".
17+
default: main
18+
type: string
19+
20+
permissions:
21+
contents: write
22+
issues: write
23+
pull-requests: write
24+
25+
env:
26+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
27+
28+
jobs:
29+
upgrade_java:
30+
name: upgrade-java
31+
runs-on: ubuntu-latest
32+
steps:
33+
34+
- name: Checkout Repo
35+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
36+
with:
37+
# Persist credentials so upgrade-provider can push a new branch.
38+
persist-credentials: true
39+
40+
- name: Setup tools
41+
uses: ./.github/actions/setup-tools
42+
with:
43+
tools: pulumictl, pulumicli, go
44+
45+
- name: Install upgrade-provider
46+
run: go install github.com/pulumi/upgrade-provider@${{ inputs.upgradeProviderVersion || 'main' }}
47+
shell: bash
48+
49+
- name: "Set up git identity"
50+
run: |
51+
git config --global user.name '[email protected]'
52+
git config --global user.email '[email protected]'
53+
shell: bash
54+
55+
- name: Upgrade Java
56+
shell: bash
57+
id: upgrade_provider
58+
env:
59+
V: ${{inputs.version}}
60+
REPO: ${{github.repository}}
61+
run: |
62+
upgrade-provider "$REPO" --kind=java --java-version="$V"
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# WARNING: This file is autogenerated - changes will be overwritten when regenerated by https://github.com/pulumi/ci-mgmt
2+
3+
name: Upgrade Java
4+
on:
5+
workflow_dispatch:
6+
inputs:
7+
version:
8+
description: |
9+
The version of pulumi/pulumi-java to upgrade to, without the 'v' prefix
10+
required: true
11+
type: string
12+
upgradeProviderVersion:
13+
description: |
14+
Version of upgrade-provider to use. This must be a valid git reference in the pulumi/upgrade-provider repo. Defaults to "main"
15+
16+
See https://go.dev/ref/mod#versions for valid versions. E.g. "v0.1.0", "main", "da25dec".
17+
default: main
18+
type: string
19+
20+
permissions:
21+
contents: write
22+
issues: write
23+
pull-requests: write
24+
25+
env:
26+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
27+
28+
jobs:
29+
upgrade_java:
30+
name: upgrade-java
31+
runs-on: ubuntu-latest
32+
steps:
33+
34+
- name: Checkout Repo
35+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
36+
with:
37+
# Persist credentials so upgrade-provider can push a new branch.
38+
persist-credentials: true
39+
40+
- name: Setup tools
41+
uses: ./.github/actions/setup-tools
42+
with:
43+
tools: pulumictl, pulumicli, go
44+
45+
- name: Install upgrade-provider
46+
run: go install github.com/pulumi/upgrade-provider@${{ inputs.upgradeProviderVersion || 'main' }}
47+
shell: bash
48+
49+
- name: "Set up git identity"
50+
run: |
51+
git config --global user.name '[email protected]'
52+
git config --global user.email '[email protected]'
53+
shell: bash
54+
55+
- name: Upgrade Java
56+
shell: bash
57+
id: upgrade_provider
58+
env:
59+
V: ${{inputs.version}}
60+
REPO: ${{github.repository}}
61+
run: |
62+
upgrade-provider "$REPO" --kind=java --java-version="$V"

0 commit comments

Comments
 (0)