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

infra: code freeze workflow #767

Merged
merged 9 commits into from
Nov 20, 2023
Merged
Changes from 1 commit
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
35 changes: 35 additions & 0 deletions .github/workflows/code-freeze.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Code Freeze

on:
pull_request:
branches:
- main

ajberdy marked this conversation as resolved.
Show resolved Hide resolved
env:
FROZEN: "false" # Set to "true" to freeze branches, "false" otherwise
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No these are just set within the workflow. Is there a benefit to moving to action variables until we want to reuse these values?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't mind the workflow for updating action variables, but there's a limitation that you can't set an empty value (for allowing all feature branch merges) and there's no documentation to attach to the place they get updated.

We could update this workflow to use a more generable/intuitive env variable UNFROZEN_PREFIX to allow us to specify feature or feature/my-feature and not rely on an empty value

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated to use repository variables

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For code freezes, will we need to publish PRs each time? If so, I think using the action variables would allow for easier changes and cleaner commit history.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense, I've update the script to use action variables

FEATURE_NAME: "" # Set your feature prefix here (leave empty to allow all feature branches)

jobs:
check-branch-name-and-title:
runs-on: ubuntu-latest
steps:
- name: Fetch PR title and check conditions
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" != feature/$FEATURE_NAME* ]] &&
[[ "$PR_TITLE" != fix:* && "$PR_TITLE" != *"[critical]"* ]]; then
echo "Error: You can only merge from branches that start with 'feature/$FEATURE_NAME', or PRs titled with 'fix: ' and containing '[critical]'."
exit 1
fi