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 a new workflow for release branch processing #11814

Merged
Merged
Show file tree
Hide file tree
Changes from 3 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
60 changes: 60 additions & 0 deletions .github/workflows/check-release-branches.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
---
name: Check release branches
on:
push:
- "release/**" # We should only react to branches like "release/networkservicemesh/*/v*.*.*"
- "!release/*" # and ignore branches like "release/v*.*.*". "**" - any character, "*" - any character except "/"

concurrency:
group: check-release-branches
cancel-in-progress: true

jobs:
check-release-branches:
name: Check release branches
runs-on: ubuntu-latest
NikitaSkrynnik marked this conversation as resolved.
Show resolved Hide resolved
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Get tag
id: tag
run: |
echo "tag=$(echo ${{ github.event.ref }} | awk -F '/' '{print $NF}')" >> $GITHUB_OUTPUT
NikitaSkrynnik marked this conversation as resolved.
Show resolved Hide resolved

- name: Check release branches
run: |
images=$(grep -roh 'apps' -e "ghcr\.io\/networkservicemesh\/ci\/.*" | cut -d'/' -f4 | cut -d':' -f1 | sort -u)
branches=$(git branch -r | grep -e "release/networkservicemesh/.*/${{ steps.tag.outputs.tag }}" | cut -d'/' -f4 | sort -u)
diff <(echo "$branches") <(echo "$images")
NikitaSkrynnik marked this conversation as resolved.
Show resolved Hide resolved

- name: Merge branches
run: |
git config --global user.email "nsmbot@networkservicmesh.io"
git config --global user.name "NSMBot"

git checkout -b release/${{ steps.tag.outputs.tag }}

branches=$(git branch -r | grep -e "release/networkservicemesh/.*/${{ steps.tag.outputs.tag }}")
for branch in $branches; do
git merge $branch
done

git push -u origin release/${{ steps.tag.outputs.tag }}

- name: Remove release branches
run: |
branches=$(git branch -r | grep -e "release/networkservicemesh/.*/${{ steps.tag.outputs.tag }}")
echo $branches
for branch in $branches; do
branch=${branch#"origin/"}
gh api \
--method DELETE \
-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
/repos/networkservicemesh/deployments-k8s/git/refs/heads/$branch
done
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
33 changes: 0 additions & 33 deletions .github/workflows/pr-for-release.yaml

This file was deleted.

Loading