Skip to content

Commit 87b965a

Browse files
authored
Pulumi enable upgrade pipeline (#124)
This CI can be run when there is a new terraform provider version present. Afterwards a PR is created which updates the bridge and the provider. Signed-off-by: Alexander Dahmen <[email protected]>
1 parent d6c8150 commit 87b965a

File tree

3 files changed

+85
-30
lines changed

3 files changed

+85
-30
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Install Pulumi Tools
2+
description: "Install Pulumi Tools for pipeline"
3+
inputs:
4+
dotnet-version:
5+
description: "Dotnet version to install"
6+
required: false
7+
default: 9.0.x
8+
node-version:
9+
description: "node version to install"
10+
required: false
11+
default: 20.x
12+
python-version:
13+
description: "python version to install"
14+
required: false
15+
default: "3.9"
16+
runs:
17+
using: "composite"
18+
steps:
19+
- name: Install pulumictl
20+
uses: jaxxstorm/action-install-gh-release@6096f2a2bbfee498ced520b6922ac2c06e990ed2 # tag=v2.1.0
21+
with:
22+
repo: pulumi/pulumictl
23+
- name: Install pulumi
24+
uses: pulumi/actions@v6
25+
- name: Setup Node
26+
uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # tag=v6.0.0
27+
with:
28+
node-version: ${{ inputs.node-version }}
29+
- name: Setup DotNet
30+
uses: actions/setup-dotnet@d4c94342e560b34958eacfc5d055d21461ed1c5d # tag=v5.0.0
31+
with:
32+
dotnet-version: ${{ inputs.dotnet-version }}
33+
- name: Setup Python
34+
uses: actions/setup-python@e797f83bcb11b83ae66e0230d6156d7c80228e7c # tag=v6.0.0
35+
with:
36+
python-version: ${{ inputs.python-version }}

.github/workflows/ci.yaml

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -32,28 +32,12 @@ jobs:
3232
# TODO: remove end
3333
- name: Unshallow clone for tags
3434
run: git fetch --prune --unshallow --tags
35-
- name: Install pulumictl
36-
uses: jaxxstorm/action-install-gh-release@6096f2a2bbfee498ced520b6922ac2c06e990ed2 # tag=v2.1.0
37-
with:
38-
repo: pulumi/pulumictl
39-
- name: Install pulumi
40-
uses: pulumi/actions@v6
4135
- name: Install Go Tools
4236
uses: ./.github/actions/gotools
4337
with:
4438
go-version: ${{ env.GO_VERSION }}
45-
- name: Setup Node
46-
uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # tag=v6.0.0
47-
with:
48-
node-version: ${{ env.NODE_VERSION }}
49-
- name: Setup DotNet
50-
uses: actions/setup-dotnet@d4c94342e560b34958eacfc5d055d21461ed1c5d # tag=v5.0.0
51-
with:
52-
dotnet-version: ${{ env.DOTNET_VERSION }}
53-
- name: Setup Python
54-
uses: actions/setup-python@e797f83bcb11b83ae66e0230d6156d7c80228e7c # tag=v6.0.0
55-
with:
56-
python-version: ${{ env.PYTHON_VERSION }}
39+
- name: Install Pulumi Tools
40+
uses: ./.github/actions/pulumitools
5741
- name: Build sdks
5842
run: make generate_sdks
5943
- name: Lint
Lines changed: 47 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,3 @@
1-
env:
2-
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3-
jobs:
4-
upgrade_provider:
5-
if: ${{ (contains(github.event.issue.title, 'Upgrade terraform-provider-')) || github.event_name == 'workflow_dispatch' }}
6-
name: upgrade-provider
7-
runs-on: ubuntu-latest
8-
steps:
9-
- name: Call upgrade provider action
10-
uses: pulumi/pulumi-upgrade-provider-action@e247104aede3eb4641f48c8ad0ea9de9346f2457 # v0.0.18
11-
with:
12-
kind: all
131
name: Upgrade provider
142

153
permissions:
@@ -21,3 +9,50 @@ on:
219
types:
2210
- opened
2311
workflow_dispatch: {}
12+
13+
env:
14+
GH_TOKEN: ${{ secrets.PR_TOKEN }}
15+
GO_VERSION: "1.24"
16+
17+
jobs:
18+
upgrade_provider:
19+
if: ${{ (contains(github.event.issue.title, 'Upgrade terraform-provider-')) || github.event_name == 'workflow_dispatch' }}
20+
name: upgrade-provider
21+
runs-on: ubuntu-latest
22+
steps:
23+
- name: Checkout
24+
uses: actions/checkout@v6
25+
# TODO: remove when this repo is made public
26+
- name: Configure Git for Private Modules
27+
run: |
28+
git config --global url."https://oauth2:${{ secrets.PR_TOKEN }}@github.com".insteadOf "https://github.com"
29+
# Sets GOPRIVATE and GONOSUMDB in order to use the git authetnication for go mod.
30+
echo "GOPRIVATE=github.com/${{ github.repository }}/*,github.com/stackitcloud/*" >> $GITHUB_ENV
31+
echo "GONOSUMDB=github.com/${{ github.repository }}/*,github.com/stackitcloud/*" >> $GITHUB_ENV
32+
# TODO: remove end
33+
- name: Unshallow clone for tags
34+
run: git fetch --prune --unshallow --tags
35+
- name: Install Go Tools
36+
uses: ./.github/actions/gotools
37+
with:
38+
go-version: ${{ env.GO_VERSION }}
39+
- name: Install Pulumi Tools
40+
uses: ./.github/actions/pulumitools
41+
- name: Get latest tag from terraform-provider-stackit and update the pulumi provider and bridge
42+
run: |
43+
git config user.name "Pulumi Generator Bot"
44+
git config user.email "[email protected]"
45+
LATEST_TAG=$(git ls-remote --tags https://github.com/stackitcloud/terraform-provider-stackit | grep -oP 'refs/tags/v\d+\.\d+\.\d+$' |sed 's/refs\/tags\///' | sort -V | tail -n 1)
46+
BRANCH_NAME="upgrade-terraform-provider-stackit-to-$LATEST_TAG"
47+
git checkout -b "$BRANCH_NAME"
48+
(cd provider && go get github.com/stackitcloud/terraform-provider-stackit@"$LATEST_TAG")
49+
(cd provider/shim && go get github.com/stackitcloud/terraform-provider-stackit@"$LATEST_TAG")
50+
make ensure
51+
make tfgen
52+
git add --all
53+
git commit -m "make tfgen"
54+
make generate_sdks
55+
git add --all
56+
git commit -m "make generate_sdks"
57+
git push --set-upstream origin "$BRANCH_NAME"
58+
gh pr create --title "Upgrade terraform-provider-stackit to $LATEST_TAG" --body "This PR was generated by the Pulumi upgrade CI pipeline" --base main --head "$BRANCH_NAME"

0 commit comments

Comments
 (0)