From b02b69f957cc2479a2940544787ca7b6f1bc7fac Mon Sep 17 00:00:00 2001 From: root Date: Wed, 6 Nov 2024 17:00:05 +0000 Subject: [PATCH 1/3] add additional release actions --- .github/dependabot.yml | 22 ++--- .github/workflows/post-release-action.yml | 50 ++++++++++++ .github/workflows/rebase-release.yml | 99 +++++++++++++++++++++++ 3 files changed, 160 insertions(+), 11 deletions(-) create mode 100644 .github/workflows/post-release-action.yml create mode 100644 .github/workflows/rebase-release.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 9e7520e3..bf741772 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -7,7 +7,7 @@ version: 2 updates: # github actions - package-ecosystem: "github-actions" - target-branch: "release-v1.12.0" + target-branch: "release-v1.13.0" directory: "/" schedule: # Check for updates to GitHub Actions every week @@ -20,7 +20,7 @@ updates: # csi-powerstore packages - package-ecosystem: docker - target-branch: "release-v1.12.0" + target-branch: "release-v1.13.0" directories: - /charts/csi-powerstore labels: @@ -37,7 +37,7 @@ updates: # csi-isilon packages - package-ecosystem: docker - target-branch: "release-v1.12.0" + target-branch: "release-v1.13.0" directories: - /charts/csi-isilon labels: @@ -54,7 +54,7 @@ updates: # csi-vxflexos packages - package-ecosystem: docker - target-branch: "release-v1.12.0" + target-branch: "release-v1.13.0" directories: - /charts/csi-vxflexos labels: @@ -71,7 +71,7 @@ updates: # csi-unity packages - package-ecosystem: docker - target-branch: "release-v1.12.0" + target-branch: "release-v1.13.0" directories: - /charts/csi-unity labels: @@ -88,7 +88,7 @@ updates: # csi-powermax packages - package-ecosystem: docker - target-branch: "release-v1.12.0" + target-branch: "release-v1.13.0" directories: - /charts/csi-powermax labels: @@ -105,7 +105,7 @@ updates: # csm-authorization packages - package-ecosystem: docker - target-branch: "release-v1.12.0" + target-branch: "release-v1.13.0" directories: - /charts/csm-authorization - /charts/csm-authorization-v2.0 @@ -123,7 +123,7 @@ updates: # karavi-observability packages - package-ecosystem: docker - target-branch: "release-v1.12.0" + target-branch: "release-v1.13.0" directories: - /charts/karavi-observability labels: @@ -143,7 +143,7 @@ updates: # csm-replication packages - package-ecosystem: docker - target-branch: "release-v1.12.0" + target-branch: "release-v1.13.0" directories: - /charts/csm-replication labels: @@ -160,7 +160,7 @@ updates: # csm-installer packages - package-ecosystem: docker - target-branch: "release-v1.12.0" + target-branch: "release-v1.13.0" directories: - /charts/csm-installer labels: @@ -177,7 +177,7 @@ updates: # installation-wizard packages - package-ecosystem: docker - target-branch: "release-v1.12.0" + target-branch: "release-v1.13.0" directories: - /installation-wizard/container-storage-modules labels: diff --git a/.github/workflows/post-release-action.yml b/.github/workflows/post-release-action.yml new file mode 100644 index 00000000..ca3046aa --- /dev/null +++ b/.github/workflows/post-release-action.yml @@ -0,0 +1,50 @@ +# Copyright (c) 2024 Dell Inc., or its subsidiaries. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 + +# This Github action updates the target-branch references for dependabot and other actions +name: Post Release Action + +on: + workflow_dispatch: + inputs: + branch_name: + description: 'Name of the new release branch, i.e. release-v1.0.0' + required: true + +jobs: + update-references: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Update branch references + run: | + BRANCH_NAME=${{ github.event.inputs.branch_name }} + grep -rl 'target-branch:' . | xargs sed -i "s/target-branch: \".*\"/target-branch: \"${BRANCH_NAME}\"/g" + + # Needed for signing commits using Github App tokens + # See: https://github.com/peter-evans/create-pull-request/blob/main/docs/concepts-guidelines.md#commit-signing + - uses: actions/create-github-app-token@v1.11.0 + id: generate-token + with: + app-id: ${{ vars.CSM_RELEASE_APP_ID }} + private-key: ${{ secrets.CSM_RELEASE_APP_PRIVATE_KEY }} + + - name: Create Pull Request + uses: peter-evans/create-pull-request@v7 + with: + token: ${{ steps.generate-token.outputs.token }} + branch: 'update-target-branch' + title: 'Update target-branch references for dependabot' + body: | + This PR updates target-branch references to the new release branch. + Auto-generated by [dell/helm-charts](https://github.com/dell/helm-charts) + sign-commits: true + commit-message: "Update target-branch references to new release branch" diff --git a/.github/workflows/rebase-release.yml b/.github/workflows/rebase-release.yml new file mode 100644 index 00000000..886a311b --- /dev/null +++ b/.github/workflows/rebase-release.yml @@ -0,0 +1,99 @@ +# Copyright (c) 2024 Dell Inc., or its subsidiaries. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 + +# This Github action keeps the CSM release branch up to date with main branch +name: Sync Release Branch with Main + +on: + push: + branches: + - main + +jobs: + rebase-branch: + runs-on: ubuntu-latest + env: + target-branch: "release-v1.13.0" + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + ref: main + + - name: Fetch all branches + run: git fetch --all + + - name: Rebase release branch with main + id: rebase + run: | + git checkout ${{ env.target-branch }} + git rebase main + + - name: Push rebase changes to new branch + if: ${{ success() && steps.rebase.outcome == 'success' }} + run: | + git checkout -b rebase-feature-branch + git push origin rebase-feature-branch + + # Needed for signing commits using Github App tokens + # See: https://github.com/peter-evans/create-pull-request/blob/main/docs/concepts-guidelines.md#commit-signing + - uses: actions/create-github-app-token@v1.11.0 + id: generate-token + if: ${{ success() && steps.rebase.outcome == 'success' }} + with: + app-id: ${{ vars.CSM_RELEASE_APP_ID }} + private-key: ${{ secrets.CSM_RELEASE_APP_PRIVATE_KEY }} + + - name: Create pull request + if: ${{ success() && steps.rebase.outcome == 'success' }} + uses: peter-evans/create-pull-request@v7 + with: + token: ${{ steps.generate-token.outputs.token }} + branch: rebase-feature-branch + base: ${{ env.target-branch }} + title: 'Rebase release branch with main' + body: | + This PR rebases the release branch with the main branch. + Auto-generated by [dell/helm-charts](https://github.com/dell/helm-charts) + sign-commits: true + commit-message: "Rebase release branch with main" + + - name: Get PR author + if: ${{ failure() && steps.rebase.outcome == 'failure' }} + id: get_pr_author + uses: actions/github-script@v7 + with: + script: | + const pr = await github.rest.pulls.list({ + owner: context.repo.owner, + repo: context.repo.repo, + state: 'closed', + base: 'main', + sort: 'updated', + direction: 'desc', + per_page: 1 + }); + const author = pr.data[0].user.login; + return { author }; + + - name: Create issue for rebase conflict + if: ${{ failure() && steps.rebase.outcome == 'failure' }} + uses: actions/github-script@v7 + with: + script: | + const author = `${{ steps.get_pr_author.outputs.author }}`; + const issueTitle = `Rebase conflict on feature-branch`; + const issueBody = `There was a conflict rebasing the feature branch onto main. Please resolve the conflicts manually.`; + await github.rest.issues.create({ + owner: context.repo.owner, + repo: context.repo.repo, + title: issueTitle, + body: issueBody, + assignees: [author], + }); From dbcd64bfb667efa37093fd8dd7dbc34d25f7617c Mon Sep 17 00:00:00 2001 From: root Date: Wed, 6 Nov 2024 22:05:12 +0000 Subject: [PATCH 2/3] update author logic for gh issues --- .github/workflows/rebase-release.yml | 33 ++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 7 deletions(-) diff --git a/.github/workflows/rebase-release.yml b/.github/workflows/rebase-release.yml index 886a311b..b37dcd2a 100644 --- a/.github/workflows/rebase-release.yml +++ b/.github/workflows/rebase-release.yml @@ -70,7 +70,7 @@ jobs: uses: actions/github-script@v7 with: script: | - const pr = await github.rest.pulls.list({ + const { data: pulls } = await github.rest.pulls.list({ owner: context.repo.owner, repo: context.repo.repo, state: 'closed', @@ -79,21 +79,40 @@ jobs: direction: 'desc', per_page: 1 }); - const author = pr.data[0].user.login; - return { author }; + const lastMergedPR = pulls.find(pr => pr.merged_at !== null); + if (!lastMergedPR) { + throw new Error('No merged pull request found.'); + } + + const author = lastMergedPR.user.login; + if (!author) { + throw new Error('No author found.'); + } + + core.setOutput('author', author); + console.log(`Author: ${author}`); + + - name: Set PR author output + if: ${{ failure() && steps.rebase.outcome == 'failure' }} + run: | + echo "PR_AUTHOR=${{ steps.get_pr_author.outputs.author }}" >> $GITHUB_ENV - name: Create issue for rebase conflict if: ${{ failure() && steps.rebase.outcome == 'failure' }} uses: actions/github-script@v7 with: script: | - const author = `${{ steps.get_pr_author.outputs.author }}`; - const issueTitle = `Rebase conflict on feature-branch`; - const issueBody = `There was a conflict rebasing the feature branch onto main. Please resolve the conflicts manually.`; + const PR_AUTHOR = process.env.PR_AUTHOR; + if (!PR_AUTHOR) { + throw new Error('PR_AUTHOR environment variable is not set.'); + } + + const issueTitle = `Rebase conflict on ${{ env.target-branch }} branch`; + const issueBody = `There was a conflict rebasing the ${{ env.target-branch }} branch onto main. Please resolve the conflicts manually. See [Sync Release Branch with Main action](https://github.com/shaynafinocchiaro/helm-charts-test/actions/workflows/rebase-release.yml) for more details.`; await github.rest.issues.create({ owner: context.repo.owner, repo: context.repo.repo, title: issueTitle, body: issueBody, - assignees: [author], + assignees: [PR_AUTHOR], }); From 55696b4a0f8fd917c3c9c48169371d85a0f01331 Mon Sep 17 00:00:00 2001 From: shaynafinocchiaro Date: Thu, 7 Nov 2024 11:02:47 -0500 Subject: [PATCH 3/3] Update post-release-action.yml --- .github/workflows/post-release-action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/post-release-action.yml b/.github/workflows/post-release-action.yml index ca3046aa..79038d2d 100644 --- a/.github/workflows/post-release-action.yml +++ b/.github/workflows/post-release-action.yml @@ -37,7 +37,7 @@ jobs: app-id: ${{ vars.CSM_RELEASE_APP_ID }} private-key: ${{ secrets.CSM_RELEASE_APP_PRIVATE_KEY }} - - name: Create Pull Request + - name: Create PR for Release Updates uses: peter-evans/create-pull-request@v7 with: token: ${{ steps.generate-token.outputs.token }}