Skip to content

Commit

Permalink
add support for patch releases and added branch whitelist checks
Browse files Browse the repository at this point in the history
  • Loading branch information
apolikamixitos committed Oct 14, 2024
1 parent 711fdd5 commit 8951285
Showing 1 changed file with 28 additions and 3 deletions.
31 changes: 28 additions & 3 deletions .github/workflows/create-release-pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,35 @@ jobs:
name: Create Release PR
runs-on: ubuntu-latest
steps:
- name: Check if a branch is whitelisted and maintained
id: branch-check
run: |
BRANCH_NAME="${GITHUB_REF#refs/heads/}"
WHITELISTED_BRANCHES=("main" "release/*")
IS_WHITELISTED=false
# Check the branch against the whitelist using wildcard matching
for BRANCH in "${WHITELISTED_BRANCHES[@]}"; do
if [[ "$BRANCH_NAME" == $BRANCH ]]; then
IS_WHITELISTED=true;
break;
fi
done
if [ "$IS_WHITELISTED" == true ]; then
echo "Branch is whitelisted: $BRANCH_NAME"
else
echo "Branch $BRANCH_NAME is not whitelisted."
exit 1
fi
echo "branch_name=${BRANCH_NAME}" >> "$GITHUB_OUTPUT"
- name: Checkout Repo
uses: actions/checkout@v4
with:
persist-credentials: false
ref: ${{ steps.branch-check.outputs.branch_name }}

- name: Check for changeset files
run: |
Expand All @@ -35,8 +60,8 @@ jobs:
id: release-pr
uses: changesets/action@aba318e9165b45b7948c60273e0b72fce0a64eb9 # v1.4.7
with:
branch: 'main'
title: 'chore(release): bump version and update changelog'
commit: 'chore(release): bump version and update changelog'
branch: ${{ steps.branch-check.outputs.branch_name }} # This branch context is ignored in this step: `https://github.com/changesets/action/blob/50750fa876cc1e54c7cb972db5e2f7271fc53d99/src/run.ts#L328`, therefore the usage of `branch`
title: 'chore(release): bump version and update changelog from `${{ steps.branch-check.outputs.branch_name }}`'
commit: 'chore(release): bump version and update changelog from `${{ steps.branch-check.outputs.branch_name }}`'
env:
GITHUB_TOKEN: ${{ secrets.PAT_TOKEN }}

0 comments on commit 8951285

Please sign in to comment.