Skip to content

Commit 5f3c8cd

Browse files
CLOUDP-277319: Added helm automation job #2 (#1870)
Added helm automation job
1 parent 5bb7dfe commit 5f3c8cd

File tree

2 files changed

+38
-14
lines changed

2 files changed

+38
-14
lines changed

.github/workflows/update-helm.yaml

Lines changed: 37 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
name: Helm update
22

3-
43
on:
54
workflow_call:
65
workflow_dispatch:
@@ -9,6 +8,10 @@ jobs:
98
verify-helm-changes:
109
name: Verify if AKO helm charts needs updates
1110
runs-on: ubuntu-latest
11+
environment: release
12+
permissions:
13+
contents: write
14+
pull-requests: write
1215
steps:
1316
- name: Checkout AKO repo
1417
uses: actions/checkout@v4
@@ -18,15 +21,24 @@ jobs:
1821
with:
1922
enable-cache: 'true'
2023

21-
- name: Configure git
22-
run: |
23-
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
24-
git config --global user.name "github-actions[bot]"
24+
- name: Generate GitHub App Token
25+
id: generate_token
26+
uses: actions/create-github-app-token@v1
27+
with:
28+
app-id: ${{ secrets.AKO_RELEASER_APP_ID }}
29+
private-key: ${{ secrets.AKO_RELEASER_RSA_KEY }}
30+
owner: ${{ github.repository_owner }}
31+
repositories: |
32+
mongodb-atlas-kubernetes
33+
helm-charts
2534
26-
- name: Checkout Helm Repo
27-
run: |
28-
git clone https://github.com/mongodb/helm-charts.git ./helm-charts-cloned
29-
ls -lah
35+
- name: Checkout Helm charts repo
36+
uses: actions/checkout@v4
37+
with:
38+
repository: mongodb/helm-charts
39+
token: ${{ steps.generate_token.outputs.token }}
40+
path: helm-charts-cloned
41+
persist-credentials: true
3042

3143
- name: Verify if CRDs were changed
3244
id: crd-check
@@ -44,17 +56,29 @@ jobs:
4456
4557
- name: Create PR for helm-charts repo
4658
env:
47-
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
59+
GH_TOKEN: ${{ steps.generate_token.outputs.token }}
4860
run: |
4961
cd ./helm-charts-cloned
5062
5163
if [[ -n $(git status --porcelain) ]]; then
52-
BRANCH_NAME=CRD-RBAC-changes-${{ github.run_id }}
53-
COMMIT_MSG="[autogenerated] update CRDs and RBAC ${{ github.run_id }}"
64+
jobname=${{ github.run_id }}
65+
if [[ -n "${{ github.event.pull_request.title }}" ]]; then
66+
jobname="${{ github.event.pull_request.title }}"
67+
fi
68+
69+
BRANCH_NAME=CRD-RBAC-changes-"${jobname}"
70+
COMMIT_MSG="[autogenerated] update CRDs and RBAC ${jobname}"
5471
echo "Changes detected. Creating PR"
72+
73+
git config --local user.email "akobot@ako-team-fake.mongodb.com"
74+
git config --local user.name "ako-releaser"
75+
5576
git checkout -b "${BRANCH_NAME}"
5677
git add .
5778
git commit -m "${COMMIT_MSG}"
58-
gh pr create -B main -H "${BRANCH_NAME}" --title "${COMMIT_MSG}" --body "${COMMIT_MSG}"
79+
80+
git push origin "${BRANCH_NAME}"
81+
82+
gh pr create --base main --head "${BRANCH_NAME}" --title "${COMMIT_MSG}" --body "${COMMIT_MSG}"
5983
fi
6084
echo "Nothing to commit"

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ DOCKER_SBOM_PLUGIN_VERSION=0.6.1
1111
# To re-generate a bundle for another specific version without changing the standard setup, you can:
1212
# - use the VERSION as arg of the bundle target (e.g make bundle VERSION=0.0.2)
1313
# - use environment variables to overwrite this value (e.g export VERSION=0.0.2)
14-
VERSION ?= $(shell git describe --tags --dirty --broken | cut -c 2-)
14+
VERSION ?= $(shell git describe --always --tags --dirty --broken | cut -c 2-)
1515

1616
# NEXT_VERSION represents a version that is higher than anything released
1717
# VERSION default value does not play well with the run target which might end up failing

0 commit comments

Comments
 (0)