-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add check-release-branches workflow to check release updates from cmd…
… repositories Signed-off-by: NikitaSkrynnik <[email protected]>
- Loading branch information
1 parent
0b7d6eb
commit d831a71
Showing
1 changed file
with
61 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
--- | ||
name: Check release branches | ||
on: | ||
push: | ||
branches: | ||
- "release/**" | ||
- "!release/*" | ||
|
||
concurrency: | ||
group: check-release-branches | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
check-release-branches: | ||
name: Check release branches | ||
runs-on: ubuntu-latest | ||
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 | ||
- 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") | ||
- name: Merge branches | ||
run: | | ||
git config --global user.email "[email protected]" | ||
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 }} |