Skip to content

Commit

Permalink
infra: code freeze workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
ajberdy authored Nov 21, 2023
1 parent dff1676 commit ccdcdef
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions .github/workflows/code-freeze.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Code Freeze

on:
pull_request:
branches:
- main
workflow_dispatch:

permissions:
contents: read

env:
FROZEN: ${{ vars.FROZEN }}
UNFROZEN_PREFIX: ${{ vars.UNFROZEN_PREFIX }}

jobs:
check-pr-frozen-status:
runs-on: ubuntu-latest
steps:
- name: Fetch PR data and check if merge allowed
if: env.FROZEN == 'true'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
PR_DATA=$(curl -s \
-H "Authorization: Bearer $GITHUB_TOKEN" \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }})
BRANCH_NAME=$(echo $PR_DATA | jq .head.ref -r)
PR_TITLE=$(echo $PR_DATA | jq .title -r)
echo $BRANCH_NAME
echo $PR_TITLE
if [[ "$BRANCH_NAME" != $UNFROZEN_PREFIX* ]] &&
[[ "$PR_TITLE" != fix:* && "$PR_TITLE" != *"[critical]"* ]]; then
echo "Error: You can only merge from branches that start with '$UNFROZEN_PREFIX', or PRs titled with 'fix: ' and containing '[critical]'."
exit 1
fi

0 comments on commit ccdcdef

Please sign in to comment.