From 6d6e23063d61a76c398942f6bae8b0f46522a743 Mon Sep 17 00:00:00 2001 From: Timur_Akhmadiev Date: Mon, 5 Dec 2022 13:39:35 +0400 Subject: [PATCH 1/4] Add post release helm action --- .github/actions/create-helm-pr/Dockerfile | 14 +++++++++++ .github/actions/create-helm-pr/action.yml | 12 +++++++++ .github/actions/create-helm-pr/entrypoint.sh | 26 ++++++++++++++++++++ .github/workflows/post-merge-helm.yml | 24 ++++++++++++++++++ 4 files changed, 76 insertions(+) create mode 100644 .github/actions/create-helm-pr/Dockerfile create mode 100644 .github/actions/create-helm-pr/action.yml create mode 100644 .github/actions/create-helm-pr/entrypoint.sh create mode 100644 .github/workflows/post-merge-helm.yml diff --git a/.github/actions/create-helm-pr/Dockerfile b/.github/actions/create-helm-pr/Dockerfile new file mode 100644 index 0000000000..da1d6db870 --- /dev/null +++ b/.github/actions/create-helm-pr/Dockerfile @@ -0,0 +1,14 @@ +FROM alpine/git:latest + + # Install GitHub CLI +RUN apk update && \ + apk add --no-cache libc6-compat bash +RUN mkdir ghcli && cd ghcli && \ + wget https://github.com/cli/cli/releases/download/v1.5.0/gh_1.5.0_linux_386.tar.gz -O ghcli.tar.gz --no-check-certificate && \ + tar --strip-components=1 -xf ghcli.tar.gz -C /usr/local + + # Copies your code file from your action repository to the filesystem path `/` of the container +COPY entrypoint.sh /home/entrypoint.sh +RUN chmod +x /home/entrypoint.sh + # Code file to execute when the docker container starts up (`entrypoint.sh`) +ENTRYPOINT ["/home/entrypoint.sh"] \ No newline at end of file diff --git a/.github/actions/create-helm-pr/action.yml b/.github/actions/create-helm-pr/action.yml new file mode 100644 index 0000000000..f190ff44d7 --- /dev/null +++ b/.github/actions/create-helm-pr/action.yml @@ -0,0 +1,12 @@ +name: 'Push files' +description: 'push file to the remote branch' +inputs: + GITHUB_TOKEN: + description: "Action token" + required: true + VERSION: + description: "operator version" + required: true +runs: + using: 'docker' + image: 'Dockerfile' \ No newline at end of file diff --git a/.github/actions/create-helm-pr/entrypoint.sh b/.github/actions/create-helm-pr/entrypoint.sh new file mode 100644 index 0000000000..65440168bd --- /dev/null +++ b/.github/actions/create-helm-pr/entrypoint.sh @@ -0,0 +1,26 @@ +#!/bin/bash + +set -eou pipefail + +git config --global --add safe.directory /github/workspace + +mkdir operator +cd operator +gh repo clone https://github.com/mongodb/mongodb-atlas-kubernetes.git +cd .. +mkdir helm +cd helm +gh repo clone https://github.com/Sugar-pack/helm-charts.git +cd .. +cp -a operator/mongodb-atlas-kubernetes/config/crd/bases/. helm/helm-charts/charts/atlas-operator-crds/templates + + +git config --global commit.gpgsign true +gh auth setup-git +cd helm/helm-charts +git add -A +BRANCH="atlas-operator-release-${VERSION}" +git checkout -b "$BRANCH" +MESSAGE="Atlas Operator Release ${VERSION}" +git commit -m "$MESSAGE" +git push --set-upstream origin "$BRANCH" \ No newline at end of file diff --git a/.github/workflows/post-merge-helm.yml b/.github/workflows/post-merge-helm.yml new file mode 100644 index 0000000000..0ba743cfcf --- /dev/null +++ b/.github/workflows/post-merge-helm.yml @@ -0,0 +1,24 @@ +name: Post merge helm + +on: + workflow_dispatch: + inputs: + version: + description: "Release version: " + required: true + push: + branches: + - 'post-release-helm' + +jobs: + create-release-branch: + name: Create Release branch + runs-on: ubuntu-latest + env: + VERSION: ${{ github.event.inputs.version }} + steps: + - name: Commit and push crds + uses: ./.github/actions/create-helm-pr + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + VERSION: "${{ env.VERSION }}" From e00c314fd9e61942a6c1494894bbcf64924721cb Mon Sep 17 00:00:00 2001 From: Timur_Akhmadiev Date: Mon, 5 Dec 2022 13:52:31 +0400 Subject: [PATCH 2/4] Update trigger --- .github/actions/create-helm-pr/action.yml | 12 --- .github/actions/create-helm-pr/entrypoint.sh | 26 ------ .../{create-helm-pr => push-files}/Dockerfile | 2 +- .github/actions/push-files/action.yml | 15 ++++ .github/actions/push-files/entrypoint.sh | 34 ++++++++ .github/workflows/post-merge-helm.yml | 83 +++++++++++++++---- 6 files changed, 119 insertions(+), 53 deletions(-) delete mode 100644 .github/actions/create-helm-pr/action.yml delete mode 100644 .github/actions/create-helm-pr/entrypoint.sh rename .github/actions/{create-helm-pr => push-files}/Dockerfile (78%) create mode 100644 .github/actions/push-files/action.yml create mode 100644 .github/actions/push-files/entrypoint.sh diff --git a/.github/actions/create-helm-pr/action.yml b/.github/actions/create-helm-pr/action.yml deleted file mode 100644 index f190ff44d7..0000000000 --- a/.github/actions/create-helm-pr/action.yml +++ /dev/null @@ -1,12 +0,0 @@ -name: 'Push files' -description: 'push file to the remote branch' -inputs: - GITHUB_TOKEN: - description: "Action token" - required: true - VERSION: - description: "operator version" - required: true -runs: - using: 'docker' - image: 'Dockerfile' \ No newline at end of file diff --git a/.github/actions/create-helm-pr/entrypoint.sh b/.github/actions/create-helm-pr/entrypoint.sh deleted file mode 100644 index 65440168bd..0000000000 --- a/.github/actions/create-helm-pr/entrypoint.sh +++ /dev/null @@ -1,26 +0,0 @@ -#!/bin/bash - -set -eou pipefail - -git config --global --add safe.directory /github/workspace - -mkdir operator -cd operator -gh repo clone https://github.com/mongodb/mongodb-atlas-kubernetes.git -cd .. -mkdir helm -cd helm -gh repo clone https://github.com/Sugar-pack/helm-charts.git -cd .. -cp -a operator/mongodb-atlas-kubernetes/config/crd/bases/. helm/helm-charts/charts/atlas-operator-crds/templates - - -git config --global commit.gpgsign true -gh auth setup-git -cd helm/helm-charts -git add -A -BRANCH="atlas-operator-release-${VERSION}" -git checkout -b "$BRANCH" -MESSAGE="Atlas Operator Release ${VERSION}" -git commit -m "$MESSAGE" -git push --set-upstream origin "$BRANCH" \ No newline at end of file diff --git a/.github/actions/create-helm-pr/Dockerfile b/.github/actions/push-files/Dockerfile similarity index 78% rename from .github/actions/create-helm-pr/Dockerfile rename to .github/actions/push-files/Dockerfile index da1d6db870..43f19bdaaa 100644 --- a/.github/actions/create-helm-pr/Dockerfile +++ b/.github/actions/push-files/Dockerfile @@ -4,7 +4,7 @@ FROM alpine/git:latest RUN apk update && \ apk add --no-cache libc6-compat bash RUN mkdir ghcli && cd ghcli && \ - wget https://github.com/cli/cli/releases/download/v1.5.0/gh_1.5.0_linux_386.tar.gz -O ghcli.tar.gz --no-check-certificate && \ + wget https://github.com/cli/cli/releases/download/v2.20.2/gh_2.20.2_linux_386.tar.gz -O ghcli.tar.gz --no-check-certificate && \ tar --strip-components=1 -xf ghcli.tar.gz -C /usr/local # Copies your code file from your action repository to the filesystem path `/` of the container diff --git a/.github/actions/push-files/action.yml b/.github/actions/push-files/action.yml new file mode 100644 index 0000000000..78d93268ef --- /dev/null +++ b/.github/actions/push-files/action.yml @@ -0,0 +1,15 @@ +name: 'Push files' +description: 'push file to the remote branch' +inputs: + GITHUB_TOKEN: + description: "Action token" + required: true + PATH_TO_COMMIT: + description: "Target file or directory which will be committed" + required: true + DESTINATION_BRANCH: + description: "Target branch" + required: true +runs: + using: 'docker' + image: 'Dockerfile' \ No newline at end of file diff --git a/.github/actions/push-files/entrypoint.sh b/.github/actions/push-files/entrypoint.sh new file mode 100644 index 0000000000..76c0b4f10c --- /dev/null +++ b/.github/actions/push-files/entrypoint.sh @@ -0,0 +1,34 @@ +#!/bin/bash + + set -eou pipefail + + git config --global --add safe.directory /github/workspace + + commit_single_file() { + # Commit to the branch + file="$1" + sha=$(git rev-parse "$DESTINATION_BRANCH:$file") || true + message="Pushing $file using GitHub API" + + echo "$DESTINATION_BRANCH:$file:$sha" + if [ "$sha" = "$DESTINATION_BRANCH:$file" ]; then + echo "File does not exist" + gh api --method PUT "/repos/:owner/:repo/contents/$file" \ + --field message="$message" \ + --field content=@<( base64 -i "$file" ) \ + --field branch="$DESTINATION_BRANCH" + else + echo "File exists" + gh api --method PUT "/repos/:owner/:repo/contents/$file" \ + --field message="$message" \ + --field content=@<( base64 -i "$file" ) \ + --field branch="$DESTINATION_BRANCH" \ + --field sha="$sha" + fi + } + + # simple 'for loop' does not work correctly, see https://github.com/koalaman/shellcheck/wiki/SC2044#correct-code + while IFS= read -r -d '' file + do + commit_single_file "$file" + done < <(find "${PATH_TO_COMMIT}" -type f -print0) \ No newline at end of file diff --git a/.github/workflows/post-merge-helm.yml b/.github/workflows/post-merge-helm.yml index 0ba743cfcf..1aae493ed8 100644 --- a/.github/workflows/post-merge-helm.yml +++ b/.github/workflows/post-merge-helm.yml @@ -1,24 +1,79 @@ name: Post merge helm on: - workflow_dispatch: - inputs: - version: - description: "Release version: " - required: true - push: - branches: - - 'post-release-helm' + push: + branches: + - post-release-helm jobs: create-release-branch: name: Create Release branch runs-on: ubuntu-latest - env: - VERSION: ${{ github.event.inputs.version }} steps: - - name: Commit and push crds - uses: ./.github/actions/create-helm-pr + - name: clone repositories + run: | + mkdir operator + cd operator + gh repo clone https://github.com/mongodb/mongodb-atlas-kubernetes.git + cd .. + mkdir helm + cd helm + gh repo clone https://github.com/Sugar-pack/helm-charts.git + cd .. env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - VERSION: "${{ env.VERSION }}" + GITHUB_TOKEN: ${{ secrets.FORK_HELM_SECRET }} + - name: copy files + run: | + cp -a operator/mongodb-atlas-kubernetes/bundle/manifests/atlas.mongodb.com_atlasbackuppolicies.yaml helm/helm-charts/charts/atlas-operator-crds/templates + cp -a operator/mongodb-atlas-kubernetes/bundle/manifests/atlas.mongodb.com_atlasbackupschedules.yaml helm/helm-charts/charts/atlas-operator-crds/templates + cp -a operator/mongodb-atlas-kubernetes/bundle/manifests/atlas.mongodb.com_atlasdatabaseusers.yaml helm/helm-charts/charts/atlas-operator-crds/templates + cp -a operator/mongodb-atlas-kubernetes/bundle/manifests/atlas.mongodb.com_atlasdeployments.yaml helm/helm-charts/charts/atlas-operator-crds/templates + cp -a operator/mongodb-atlas-kubernetes/bundle/manifests/atlas.mongodb.com_atlasprojects.yaml helm/helm-charts/charts/atlas-operator-crds/templates + cp -a operator/mongodb-atlas-kubernetes/bundle/manifests/atlas.mongodb.com_atlasteams.yaml helm/helm-charts/charts/atlas-operator-crds/templates + - name: edit versions + run: | + VERSION="test2" + cd helm/helm-charts/charts/atlas-operator-crds + sed -i -r 's/version:....../version: '"$VERSION"'/g' Chart.yaml + sed -i -r 's/appVersion:....../appVersion: '"$VERSION"'/g' Chart.yaml + cd .. + cd atlas-operator + sed -i -r 's/version:.\x22.....\x22/version: \x22'"$VERSION"'\x22/g' Chart.yaml + sed -i -r 's/version:......$/version: '"$VERSION"'/g' Chart.yaml + sed -i -r 's/appVersion:....../appVersion: '"$VERSION"'/g' Chart.yaml + cd .. + - name: checkout + run: | + cd operator/mongodb-atlas-kubernetes + git fetch + git branch -v -a + git checkout post-release-helm + cd ../.. + - name: git config + id: git-config + run: | + VERSION="test3" + branch="atlas-operator-release-$VERSION" + echo "branch=$branch" >> "$GITHUB_OUTPUT" + cd helm/helm-charts + env: + GITHUB_TOKEN: ${{ secrets.FORK_HELM_SECRET }} + - name: Commit and push chart + run: | + cp operator/mongodb-atlas-kubernetes/.github/actions/push-files/entrypoint.sh helm/helm-charts + cd helm/helm-charts + chmod +x entrypoint.sh + git checkout -b "test-sign1" + git push origin "test-sign1" + ./entrypoint.sh + env: + GITHUB_TOKEN: ${{ secrets.FORK_HELM_SECRET }} + PATH_TO_COMMIT: "charts/atlas-operator-crds/Chart.yaml" + DESTINATION_BRANCH: "release/test3" + - name: create pull request + run: | + cd helm/helm-charts + gh pr create --title "update atlas operator version to $VERSION" --body "update atlas operator version to $VERSION" --base branch-for-pr --head ${{ steps.git-config.outputs.branch }} --repo Sugar-pack/helm-charts + env: + GITHUB_TOKEN: ${{ secrets.FORK_HELM_SECRET }} + From ca65554726b701de6f3d4d1685201d6f8e5dbcc5 Mon Sep 17 00:00:00 2001 From: Timur_Akhmadiev Date: Wed, 7 Dec 2022 13:11:46 +0400 Subject: [PATCH 3/4] Update trigger --- .github/actions/push-files/Dockerfile | 14 --------- .github/actions/push-files/action.yml | 15 --------- .github/actions/push-files/entrypoint.sh | 6 ++-- .github/workflows/post-merge-helm.yml | 40 ++++++++++++++++++------ 4 files changed, 34 insertions(+), 41 deletions(-) delete mode 100644 .github/actions/push-files/Dockerfile delete mode 100644 .github/actions/push-files/action.yml diff --git a/.github/actions/push-files/Dockerfile b/.github/actions/push-files/Dockerfile deleted file mode 100644 index 43f19bdaaa..0000000000 --- a/.github/actions/push-files/Dockerfile +++ /dev/null @@ -1,14 +0,0 @@ -FROM alpine/git:latest - - # Install GitHub CLI -RUN apk update && \ - apk add --no-cache libc6-compat bash -RUN mkdir ghcli && cd ghcli && \ - wget https://github.com/cli/cli/releases/download/v2.20.2/gh_2.20.2_linux_386.tar.gz -O ghcli.tar.gz --no-check-certificate && \ - tar --strip-components=1 -xf ghcli.tar.gz -C /usr/local - - # Copies your code file from your action repository to the filesystem path `/` of the container -COPY entrypoint.sh /home/entrypoint.sh -RUN chmod +x /home/entrypoint.sh - # Code file to execute when the docker container starts up (`entrypoint.sh`) -ENTRYPOINT ["/home/entrypoint.sh"] \ No newline at end of file diff --git a/.github/actions/push-files/action.yml b/.github/actions/push-files/action.yml deleted file mode 100644 index 78d93268ef..0000000000 --- a/.github/actions/push-files/action.yml +++ /dev/null @@ -1,15 +0,0 @@ -name: 'Push files' -description: 'push file to the remote branch' -inputs: - GITHUB_TOKEN: - description: "Action token" - required: true - PATH_TO_COMMIT: - description: "Target file or directory which will be committed" - required: true - DESTINATION_BRANCH: - description: "Target branch" - required: true -runs: - using: 'docker' - image: 'Dockerfile' \ No newline at end of file diff --git a/.github/actions/push-files/entrypoint.sh b/.github/actions/push-files/entrypoint.sh index 76c0b4f10c..4171b81017 100644 --- a/.github/actions/push-files/entrypoint.sh +++ b/.github/actions/push-files/entrypoint.sh @@ -13,17 +13,19 @@ echo "$DESTINATION_BRANCH:$file:$sha" if [ "$sha" = "$DESTINATION_BRANCH:$file" ]; then echo "File does not exist" - gh api --method PUT "/repos/:owner/:repo/contents/$file" \ + echo gh api --method PUT "/repos/:owner/:repo/contents/$file" \ --field message="$message" \ --field content=@<( base64 -i "$file" ) \ --field branch="$DESTINATION_BRANCH" + echo "$file pushed to $DESTINATION_BRANCH" else echo "File exists" - gh api --method PUT "/repos/:owner/:repo/contents/$file" \ + echo gh api --method PUT "/repos/:owner/:repo/contents/$file" \ --field message="$message" \ --field content=@<( base64 -i "$file" ) \ --field branch="$DESTINATION_BRANCH" \ --field sha="$sha" + echo "$file pushed to $DESTINATION_BRANCH" fi } diff --git a/.github/workflows/post-merge-helm.yml b/.github/workflows/post-merge-helm.yml index 1aae493ed8..951d96ffe8 100644 --- a/.github/workflows/post-merge-helm.yml +++ b/.github/workflows/post-merge-helm.yml @@ -7,6 +7,8 @@ on: jobs: create-release-branch: + permissions: + contents: write name: Create Release branch runs-on: ubuntu-latest steps: @@ -14,14 +16,14 @@ jobs: run: | mkdir operator cd operator - gh repo clone https://github.com/mongodb/mongodb-atlas-kubernetes.git + git clone https://github.com/mongodb/mongodb-atlas-kubernetes.git cd .. mkdir helm cd helm - gh repo clone https://github.com/Sugar-pack/helm-charts.git + git clone https://github.com/mongodb/helm-charts.git cd .. env: - GITHUB_TOKEN: ${{ secrets.FORK_HELM_SECRET }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: copy files run: | cp -a operator/mongodb-atlas-kubernetes/bundle/manifests/atlas.mongodb.com_atlasbackuppolicies.yaml helm/helm-charts/charts/atlas-operator-crds/templates @@ -55,23 +57,41 @@ jobs: VERSION="test3" branch="atlas-operator-release-$VERSION" echo "branch=$branch" >> "$GITHUB_OUTPUT" - cd helm/helm-charts env: - GITHUB_TOKEN: ${{ secrets.FORK_HELM_SECRET }} - - name: Commit and push chart + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: test run: | cp operator/mongodb-atlas-kubernetes/.github/actions/push-files/entrypoint.sh helm/helm-charts cd helm/helm-charts chmod +x entrypoint.sh - git checkout -b "test-sign1" - git push origin "test-sign1" + git checkout -b ${{ steps.git-config.outputs.branch }} + gh auth setup-git + git push origin ${{ steps.git-config.outputs.branch }} + env: + GITHUB_TOKEN: ${{ secrets.FORK_HELM_SECRET }} + - name: Commit and push crds chart + run: | + cd helm/helm-charts + git add . + git fetch origin atlas-operator-release-test3 + git init + message="test msg" ./entrypoint.sh +# FILE_TO_COMMIT="charts/atlas-operator-crds/Chart.yaml" +# DESTINATION_BRANCH="atlas-operator-release-test3" +# MESSAGE="auto commit $FILE_TO_COMMIT" +# SHA=$(git rev-parse "$DESTINATION_BRANCH:$FILE_TO_COMMIT") || true +# gh api --method PUT /repos/:owner/:repo/contents/$FILE_TO_COMMIT \ +# --field message="$MESSAGE" \ +# --field content=@<( base64 -i $FILE_TO_COMMIT ) \ +# --field branch="$DESTINATION_BRANCH" \ +# --field sha="$SHA" env: GITHUB_TOKEN: ${{ secrets.FORK_HELM_SECRET }} + DESTINATION_BRANCH: ${{ steps.git-config.outputs.branch }} PATH_TO_COMMIT: "charts/atlas-operator-crds/Chart.yaml" - DESTINATION_BRANCH: "release/test3" - name: create pull request - run: | + run: | cd helm/helm-charts gh pr create --title "update atlas operator version to $VERSION" --body "update atlas operator version to $VERSION" --base branch-for-pr --head ${{ steps.git-config.outputs.branch }} --repo Sugar-pack/helm-charts env: From 716b72833d6f1354b983adfc45717a0e15d9d3c6 Mon Sep 17 00:00:00 2001 From: Timur_Akhmadiev Date: Thu, 8 Dec 2022 09:32:33 +0400 Subject: [PATCH 4/4] Update workflow --- .github/actions/push-files/entrypoint.sh | 36 --------- .github/workflows/post-merge-helm.yml | 99 ------------------------ .github/workflows/release-post-merge.yml | 10 +++ 3 files changed, 10 insertions(+), 135 deletions(-) delete mode 100644 .github/actions/push-files/entrypoint.sh delete mode 100644 .github/workflows/post-merge-helm.yml diff --git a/.github/actions/push-files/entrypoint.sh b/.github/actions/push-files/entrypoint.sh deleted file mode 100644 index 4171b81017..0000000000 --- a/.github/actions/push-files/entrypoint.sh +++ /dev/null @@ -1,36 +0,0 @@ -#!/bin/bash - - set -eou pipefail - - git config --global --add safe.directory /github/workspace - - commit_single_file() { - # Commit to the branch - file="$1" - sha=$(git rev-parse "$DESTINATION_BRANCH:$file") || true - message="Pushing $file using GitHub API" - - echo "$DESTINATION_BRANCH:$file:$sha" - if [ "$sha" = "$DESTINATION_BRANCH:$file" ]; then - echo "File does not exist" - echo gh api --method PUT "/repos/:owner/:repo/contents/$file" \ - --field message="$message" \ - --field content=@<( base64 -i "$file" ) \ - --field branch="$DESTINATION_BRANCH" - echo "$file pushed to $DESTINATION_BRANCH" - else - echo "File exists" - echo gh api --method PUT "/repos/:owner/:repo/contents/$file" \ - --field message="$message" \ - --field content=@<( base64 -i "$file" ) \ - --field branch="$DESTINATION_BRANCH" \ - --field sha="$sha" - echo "$file pushed to $DESTINATION_BRANCH" - fi - } - - # simple 'for loop' does not work correctly, see https://github.com/koalaman/shellcheck/wiki/SC2044#correct-code - while IFS= read -r -d '' file - do - commit_single_file "$file" - done < <(find "${PATH_TO_COMMIT}" -type f -print0) \ No newline at end of file diff --git a/.github/workflows/post-merge-helm.yml b/.github/workflows/post-merge-helm.yml deleted file mode 100644 index 951d96ffe8..0000000000 --- a/.github/workflows/post-merge-helm.yml +++ /dev/null @@ -1,99 +0,0 @@ -name: Post merge helm - -on: - push: - branches: - - post-release-helm - -jobs: - create-release-branch: - permissions: - contents: write - name: Create Release branch - runs-on: ubuntu-latest - steps: - - name: clone repositories - run: | - mkdir operator - cd operator - git clone https://github.com/mongodb/mongodb-atlas-kubernetes.git - cd .. - mkdir helm - cd helm - git clone https://github.com/mongodb/helm-charts.git - cd .. - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - name: copy files - run: | - cp -a operator/mongodb-atlas-kubernetes/bundle/manifests/atlas.mongodb.com_atlasbackuppolicies.yaml helm/helm-charts/charts/atlas-operator-crds/templates - cp -a operator/mongodb-atlas-kubernetes/bundle/manifests/atlas.mongodb.com_atlasbackupschedules.yaml helm/helm-charts/charts/atlas-operator-crds/templates - cp -a operator/mongodb-atlas-kubernetes/bundle/manifests/atlas.mongodb.com_atlasdatabaseusers.yaml helm/helm-charts/charts/atlas-operator-crds/templates - cp -a operator/mongodb-atlas-kubernetes/bundle/manifests/atlas.mongodb.com_atlasdeployments.yaml helm/helm-charts/charts/atlas-operator-crds/templates - cp -a operator/mongodb-atlas-kubernetes/bundle/manifests/atlas.mongodb.com_atlasprojects.yaml helm/helm-charts/charts/atlas-operator-crds/templates - cp -a operator/mongodb-atlas-kubernetes/bundle/manifests/atlas.mongodb.com_atlasteams.yaml helm/helm-charts/charts/atlas-operator-crds/templates - - name: edit versions - run: | - VERSION="test2" - cd helm/helm-charts/charts/atlas-operator-crds - sed -i -r 's/version:....../version: '"$VERSION"'/g' Chart.yaml - sed -i -r 's/appVersion:....../appVersion: '"$VERSION"'/g' Chart.yaml - cd .. - cd atlas-operator - sed -i -r 's/version:.\x22.....\x22/version: \x22'"$VERSION"'\x22/g' Chart.yaml - sed -i -r 's/version:......$/version: '"$VERSION"'/g' Chart.yaml - sed -i -r 's/appVersion:....../appVersion: '"$VERSION"'/g' Chart.yaml - cd .. - - name: checkout - run: | - cd operator/mongodb-atlas-kubernetes - git fetch - git branch -v -a - git checkout post-release-helm - cd ../.. - - name: git config - id: git-config - run: | - VERSION="test3" - branch="atlas-operator-release-$VERSION" - echo "branch=$branch" >> "$GITHUB_OUTPUT" - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - name: test - run: | - cp operator/mongodb-atlas-kubernetes/.github/actions/push-files/entrypoint.sh helm/helm-charts - cd helm/helm-charts - chmod +x entrypoint.sh - git checkout -b ${{ steps.git-config.outputs.branch }} - gh auth setup-git - git push origin ${{ steps.git-config.outputs.branch }} - env: - GITHUB_TOKEN: ${{ secrets.FORK_HELM_SECRET }} - - name: Commit and push crds chart - run: | - cd helm/helm-charts - git add . - git fetch origin atlas-operator-release-test3 - git init - message="test msg" - ./entrypoint.sh -# FILE_TO_COMMIT="charts/atlas-operator-crds/Chart.yaml" -# DESTINATION_BRANCH="atlas-operator-release-test3" -# MESSAGE="auto commit $FILE_TO_COMMIT" -# SHA=$(git rev-parse "$DESTINATION_BRANCH:$FILE_TO_COMMIT") || true -# gh api --method PUT /repos/:owner/:repo/contents/$FILE_TO_COMMIT \ -# --field message="$MESSAGE" \ -# --field content=@<( base64 -i $FILE_TO_COMMIT ) \ -# --field branch="$DESTINATION_BRANCH" \ -# --field sha="$SHA" - env: - GITHUB_TOKEN: ${{ secrets.FORK_HELM_SECRET }} - DESTINATION_BRANCH: ${{ steps.git-config.outputs.branch }} - PATH_TO_COMMIT: "charts/atlas-operator-crds/Chart.yaml" - - name: create pull request - run: | - cd helm/helm-charts - gh pr create --title "update atlas operator version to $VERSION" --body "update atlas operator version to $VERSION" --base branch-for-pr --head ${{ steps.git-config.outputs.branch }} --repo Sugar-pack/helm-charts - env: - GITHUB_TOKEN: ${{ secrets.FORK_HELM_SECRET }} - diff --git a/.github/workflows/release-post-merge.yml b/.github/workflows/release-post-merge.yml index 1717b26234..0d74ee3ff2 100644 --- a/.github/workflows/release-post-merge.yml +++ b/.github/workflows/release-post-merge.yml @@ -45,6 +45,16 @@ jobs: echo "version=$version" >> $GITHUB_OUTPUT echo "tag=$tag" >> $GITHUB_OUTPUT + - name: Trigger helm post release workflow + run: | + curl \ + -X POST \ + -H "Accept: application/vnd.github+json" \ + -H "Authorization: Bearer ${{ secrets.HELM_REPO_TOKEN }}"\ + -H "X-GitHub-Api-Version: 2022-11-28" \ + https://api.github.com/repos/mongodb/helm-charts/actions/workflows/post-atlas-operator-release.yaml/dispatches \ + -d '{"ref":"main","inputs":{"version":"'"${{ steps.tag.outputs.version }}"'"}}' + - name: Check out code into the Go module directory uses: actions/checkout@v3.1.0 with: