Skip to content

Commit a3b126e

Browse files
committed
Pulumi enable upgrade pipeline
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 a3b126e

File tree

1 file changed

+94
-12
lines changed

1 file changed

+94
-12
lines changed
Lines changed: 94 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,97 @@ on:
219
types:
2210
- opened
2311
workflow_dispatch: {}
12+
13+
env:
14+
GH_TOKEN: ${{ secrets.PR_TOKEN }}
15+
GO_VERSION: "1.24"
16+
DOTNET_VERSION: 9.0.x
17+
NODE_VERSION: 20.x
18+
PYTHON_VERSION: "3.9"
19+
20+
jobs:
21+
upgrade_provider:
22+
if: ${{ (contains(github.event.issue.title, 'Upgrade terraform-provider-')) || github.event_name == 'workflow_dispatch' }}
23+
name: upgrade-provider
24+
runs-on: ubuntu-latest
25+
steps:
26+
- name: Checkout
27+
uses: actions/checkout@v6
28+
# TODO: remove when this repo is made public
29+
- name: Configure Git for Private Modules
30+
run: |
31+
git config --global url."https://oauth2:${{ secrets.PR_TOKEN }}@github.com".insteadOf "https://github.com"
32+
# Sets GOPRIVATE and GONOSUMDB in order to use the git authetnication for go mod.
33+
echo "GOPRIVATE=github.com/${{ github.repository }}/*,github.com/stackitcloud/*" >> $GITHUB_ENV
34+
echo "GONOSUMDB=github.com/${{ github.repository }}/*,github.com/stackitcloud/*" >> $GITHUB_ENV
35+
# TODO: remove end
36+
- name: Unshallow clone for tags
37+
run: git fetch --prune --unshallow --tags
38+
- name: Install pulumictl
39+
uses: jaxxstorm/action-install-gh-release@6096f2a2bbfee498ced520b6922ac2c06e990ed2 # tag=v2.1.0
40+
with:
41+
repo: pulumi/pulumictl
42+
- name: Install pulumi
43+
uses: pulumi/actions@v6
44+
- name: Install Go Tools
45+
uses: ./.github/actions/gotools
46+
with:
47+
go-version: ${{ env.GO_VERSION }}
48+
- name: Setup Node
49+
uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # tag=v6.0.0
50+
with:
51+
node-version: ${{ env.NODE_VERSION }}
52+
- name: Setup DotNet
53+
uses: actions/setup-dotnet@d4c94342e560b34958eacfc5d055d21461ed1c5d # tag=v5.0.0
54+
with:
55+
dotnet-version: ${{ env.DOTNET_VERSION }}
56+
- name: Setup Python
57+
uses: actions/setup-python@e797f83bcb11b83ae66e0230d6156d7c80228e7c # tag=v6.0.0
58+
with:
59+
python-version: ${{ env.PYTHON_VERSION }}
60+
- name: Test update provider and bridge and create a PR
61+
run: |
62+
git config user.name "Pulumi Generator Bot"
63+
git config user.email "[email protected]"
64+
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)
65+
echo "$LATEST_TAG"
66+
BRANCH_NAME="upgrade-terraform-provider-stackit-to-$LATEST_TAG"
67+
echo "$BRANCH_NAME"
68+
git checkout -b "$BRANCH_NAME"
69+
(cd provider && go get github.com/stackitcloud/terraform-provider-stackit@"$LATEST_TAG")
70+
(cd provider/shim && go get github.com/stackitcloud/terraform-provider-stackit@"$LATEST_TAG")
71+
git status
72+
make ensure
73+
make tfgen
74+
git add --all
75+
git commit -m "make tfgen"
76+
make generate_sdks
77+
git add --all
78+
git commit -m "make generate_sdks"
79+
git push --set-upstream origin "$BRANCH_NAME"
80+
gh pr create --title "Upgrade terraform-provider-stackit to $LATEST_TAG" --base main --head "$BRANCH_NAME"
81+
82+
83+
84+
85+
# remove code below is not needed anymore since the upgrade-provider action is not working correctly
86+
# - name: Install misc
87+
# run: |
88+
# sudo apt update -y && sudo apt install -y curl
89+
# sudo install -dm 755 /etc/apt/keyrings
90+
# curl -fSs https://mise.jdx.dev/gpg-key.pub | sudo tee /etc/apt/keyrings/mise-archive-keyring.pub 1> /dev/null
91+
# echo "deb [signed-by=/etc/apt/keyrings/mise-archive-keyring.pub arch=amd64] https://mise.jdx.dev/deb stable main" | sudo tee /etc/apt/sources.list.d/mise.list
92+
# sudo apt update
93+
# sudo apt install -y mise
94+
# - name: Call upgrade provider action
95+
# uses: pulumi/pulumi-upgrade-provider-action@e247104aede3eb4641f48c8ad0ea9de9346f2457 # v0.0.18
96+
# with:
97+
# kind: all
98+
# - name: Test if all was added
99+
# run: git status
100+
# - name: Run make generate_sdks again
101+
# run: make generate_sdks
102+
# - name: Test git status afterwards
103+
# run: git status
104+
105+

0 commit comments

Comments
 (0)