Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add github actions to aid the release process #557

Merged
merged 3 commits into from
Nov 7, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand All @@ -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:
Expand All @@ -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:
Expand All @@ -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:
Expand All @@ -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:
Expand All @@ -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
Expand All @@ -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:
Expand All @@ -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:
Expand All @@ -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:
Expand All @@ -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:
Expand Down
50 changes: 50 additions & 0 deletions .github/workflows/post-release-action.yml
Original file line number Diff line number Diff line change
@@ -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/[email protected]
id: generate-token
with:
app-id: ${{ vars.CSM_RELEASE_APP_ID }}
private-key: ${{ secrets.CSM_RELEASE_APP_PRIVATE_KEY }}

- name: Create Pull Request
shaynafinocchiaro marked this conversation as resolved.
Show resolved Hide resolved
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)
ChristianAtDell marked this conversation as resolved.
Show resolved Hide resolved
sign-commits: true
commit-message: "Update target-branch references to new release branch"
118 changes: 118 additions & 0 deletions .github/workflows/rebase-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
# 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/[email protected]
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 { data: pulls } = 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 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 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: [PR_AUTHOR],
});