Skip to content

Commit

Permalink
chore(operator): adds workflow to block merging operator release-please
Browse files Browse the repository at this point in the history
PR when missing prepare release PR
  • Loading branch information
JoaoBraveCoding committed Apr 9, 2024
1 parent a662b3e commit e7a55f1
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions .github/workflows/operator-check-prepare-release-commit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: operator-check-prepare-release-commit

on:
pull_request:
paths:
- 'operator/**'
branches:
- master

jobs:
check-commit:
runs-on: ubuntu-latest
if: |
github.event.pull_request.head.ref == 'release-please--branches--master--components--operator' &&
contains(github.event.pull_request.title, 'chore( operator): community release')
steps:
- name: Extract release version
id: pr_semver
run: |
PR_TITLE="${{ github.event.pull_request.title }}"
SEMVER=$(echo "$PR_TITLE" | sed -n 's/^chore( operator): community release \([0-9]\+\.[0-9]\+\.[0-9]\+\)$/\1/p')
echo "semver=$SEMVER" >> $GITHUB_OUTPUT
- name: Checkout code
uses: actions/checkout@v4
with:
ref: master
path: "release"

- name: Check main commits for prepare release commit
id: check_commit
env:
GH_TOKEN: ${{ secrets.MY_RELEASE_PLEASE_TOKEN }}
working-directory: "release"
run: |
COMMIT=$(gh search commits "chore(operator): prepare community release v${{ steps.pr_semver.outputs.semver }}")
if [ -n "$COMMIT" ]; then
echo "Matching commit found."
echo "found=true" >> $GITHUB_OUTPUT
else
echo "No matching commit found."
echo "found=false" >> $GITHUB_OUTPUT
fi
- name: Fail if no prepare release commit
if: steps.check_commit.outputs.found == 'false'
run: |
echo "No prepare release commit found for the release version ${{ steps.pr_semver.outputs.semver }}"
exit 1

0 comments on commit e7a55f1

Please sign in to comment.