Skip to content

Commit 39bd332

Browse files
authored
chore: refactor updatecli execution (#329)
* chore: refactor updatecli execution Signed-off-by: Olivier Vernin <olivier@vernin.me> * fix: merge jobs Signed-off-by: Olivier Vernin <olivier@vernin.me> --------- Signed-off-by: Olivier Vernin <olivier@vernin.me>
1 parent c9fc56b commit 39bd332

File tree

4 files changed

+93
-38
lines changed

4 files changed

+93
-38
lines changed

.github/workflows/updatecli.yaml

Lines changed: 22 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,35 @@
1-
name: updatecli
1+
name: Updatecli
22
on:
3+
release:
34
workflow_dispatch:
4-
push:
5-
pull_request:
65
schedule:
7-
# * is a special character in YAML so you have to quote this string
8-
# Run every hour
9-
- cron: '0 * * * *'
6+
# Run at 12:00 every Saterday every 14 days
7+
- cron: '0 12 */14 * 6'
8+
109
jobs:
11-
updatecli:
12-
runs-on: ubuntu-24.04
10+
prepare:
11+
runs-on: ubuntu-latest
1312
steps:
1413
- name: "Checkout"
15-
uses: "actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8" # v5.0.0
14+
uses: "actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3" # v6.0.0
15+
1616
- name: "Setup updatecli"
17-
uses: "updatecli/updatecli-action@v2"
18-
- name: Set up Go
19-
uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5.5.0
17+
uses: "updatecli/updatecli-action@5ca36367fadc6ad94d590984fd9c696e783ec635" # v2.96.0
2018
with:
21-
go-version-file: 'go.mod'
22-
check-latest: true
23-
id: go
24-
- name: Install Swagger
25-
run: "go install github.com/swaggo/swag/cmd/swag@$SWAGGER_VERSION"
26-
env:
27-
SWAGGER_VERSION: v1.16.6
28-
- name: "Run updatecli in dryrun"
29-
run: "updatecli compose diff"
30-
env:
31-
GITHUB_ACTOR: ${{ github.actor }}
32-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
33-
- uses: tibdex/github-app-token@3beb63f4bd073e61482598c45c71c1019b59b73a # v2.1.0
34-
id: generate_token
35-
if: github.ref == 'refs/heads/main'
19+
version: "v0.113.0-rc.1"
20+
21+
- name: "Set up Go"
22+
uses: "actions/setup-go@4dc6199c7b1a012772edbd06daecab0f50c9053c" # v6.1.0
3623
with:
37-
app_id: ${{ secrets.UPDATECLIBOT_APP_ID }}
38-
private_key: ${{ secrets.UPDATECLIBOT_APP_PRIVKEY }}
39-
- name: "Login Udash"
40-
if: github.ref == 'refs/heads/main'
41-
run: "updatecli udash login --experimental --api-url $UPDATECLI_UDASH_API_URL --oauth-access-token $UPDATECLI_UDASH_ACCESS_TOKEN $UPDATECLI_UDASH_URL"
24+
go-version-file: "go.mod"
25+
id: go
26+
27+
- name: "Run updatecli"
28+
run: updatecli compose apply --clean-git-branches=true --experimental
4229
env:
30+
UPDATECLI_GITHUB_APP_CLIENT_ID: ${{ secrets.UPDATECLIBOT_APP_ID }}
31+
UPDATECLI_GITHUB_APP_PRIVATE_KEY: ${{ secrets.UPDATECLIBOT_APP_PRIVKEY }}
32+
UPDATECLI_GITHUB_APP_INSTALLATION_ID: ${{ secrets.UPDATECLIBOT_APP_INSTALLATION_ID }}
4333
UPDATECLI_UDASH_API_URL: ${{ secrets.UPDATECLI_UDASH_API_URL }}
4434
UPDATECLI_UDASH_ACCESS_TOKEN: ${{ secrets.UPDATECLI_UDASH_ACCESS_TOKEN }}
4535
UPDATECLI_UDASH_URL: ${{ secrets.UPDATECLI_UDASH_URL }}
46-
- name: "Run updatecli"
47-
if: github.ref == 'refs/heads/main'
48-
run: "updatecli compose apply --experimental"
49-
env:
50-
GITHUB_ACTOR: ${{ secrets.UPDATECLI_BOT_GITHUB_ACTOR }}
51-
GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Updatecli Test
2+
3+
on:
4+
pull_request:
5+
6+
permissions:
7+
contents: read
8+
9+
jobs:
10+
prepare:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: "Checkout"
14+
uses: "actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3" # v6.0.0
15+
16+
- name: "Setup updatecli"
17+
uses: "updatecli/updatecli-action@5ca36367fadc6ad94d590984fd9c696e783ec635" # v2.96.0
18+
with:
19+
version: "v0.113.0-rc.1"
20+
21+
- name: "Set up Go"
22+
uses: "actions/setup-go@4dc6199c7b1a012772edbd06daecab0f50c9053c" # v6.1.0
23+
with:
24+
go-version-file: "go.mod"
25+
id: go
26+
27+
- name: "Test updatecli in dry-run mode"
28+
run: "updatecli compose diff"
29+
env:
30+
# This step is executed in untrusted context. We use a GitHub token with minimal permissions.
31+
GITHUB_ACTOR: ${{ github.actor }}
32+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Updatecli - Update
2+
on:
3+
workflow_dispatch:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
prepare:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: "Checkout"
13+
uses: "actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3" # v6.0.0
14+
15+
- name: "Setup updatecli"
16+
uses: "updatecli/updatecli-action@5ca36367fadc6ad94d590984fd9c696e783ec635" # v2.96.0
17+
with:
18+
version: "v0.113.0-rc.1"
19+
20+
- name: "Set up Go"
21+
uses: "actions/setup-go@4dc6199c7b1a012772edbd06daecab0f50c9053c" # v6.1.0
22+
with:
23+
go-version-file: "go.mod"
24+
id: go
25+
26+
- name: "Run updatecli only on existing pipelines"
27+
run: updatecli compose apply --clean-git-branches=true --existing-only=true --experimental
28+
env:
29+
UPDATECLI_GITHUB_APP_CLIENT_ID: ${{ secrets.UPDATECLIBOT_APP_ID }}
30+
UPDATECLI_GITHUB_APP_PRIVATE_KEY: ${{ secrets.UPDATECLIBOT_APP_PRIVKEY }}
31+
UPDATECLI_GITHUB_APP_INSTALLATION_ID: ${{ secrets.UPDATECLIBOT_APP_INSTALLATION_ID }}
32+
UPDATECLI_UDASH_API_URL: ${{ secrets.UPDATECLI_UDASH_API_URL }}
33+
UPDATECLI_UDASH_ACCESS_TOKEN: ${{ secrets.UPDATECLI_UDASH_ACCESS_TOKEN }}
34+
UPDATECLI_UDASH_URL: ${{ secrets.UPDATECLI_UDASH_URL }}

updatecli-compose.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,8 @@ policies:
4949
values:
5050
- updatecli/values.d/scm.yaml
5151
- updatecli/values.d/githubaction.yaml
52+
53+
- name: Handle Updatecli version in GitHub action
54+
policy: ghcr.io/updatecli/policies/updatecli/githubaction:0.7.0@sha256:a97518f118b03d2f63f45378e1961028b07c23d53db91db892893ff240fa5f4e
55+
values:
56+
- updatecli/values.d/scm.yaml

0 commit comments

Comments
 (0)