Skip to content

Commit 439ba29

Browse files
committed
next attempt to secops check
1 parent e8b4daf commit 439ba29

File tree

1 file changed

+19
-38
lines changed

1 file changed

+19
-38
lines changed
Lines changed: 19 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,67 +1,48 @@
1-
name: Release Branch Check
2-
3-
on:
4-
pull_request:
5-
branches:
6-
- 'release/**'
7-
- 'main'
8-
types: [opened, synchronize, reopened]
9-
101
jobs:
112
validate-release-branch:
123
runs-on: ubuntu-latest
4+
env:
5+
RELEASE_BRANCH_PREFIX: release/
6+
CURRENT_RELEASE: v2
7+
TARGET_BRANCH: ${{ github.base_ref }}
8+
PR_TITLE: ${{ github.event.pull_request.title }}
9+
PR_LABELS_JSON: ${{ toJson(github.event.pull_request.labels) }}
10+
BASE_SHA: ${{ github.event.pull_request.base.sha }}
11+
HEAD_SHA: ${{ github.event.pull_request.head.sha }}
1312
steps:
1413
- name: Checkout repository
1514
uses: actions/checkout@v4
1615

17-
- name: Prepare environment
18-
run: |
19-
{
20-
echo "RELEASE_BRANCH_PREFIX=release/"
21-
echo "CURRENT_RELEASE=v2"
22-
echo "TARGET_BRANCH=${{ github.base_ref }}"
23-
echo "PR_TITLE=${{ github.event.pull_request.title }}"
24-
echo "PR_LABELS=${{ github.event.pull_request.labels.*.name }}"
25-
echo "BASE_SHA=${{ github.event.pull_request.base.sha }}"
26-
echo "HEAD_SHA=${{ github.event.pull_request.head.sha }}"
27-
} >> "$GITHUB_ENV"
28-
2916
- name: Validate release branch
3017
run: |
31-
# First check if it's a release branch
18+
LABELS=$(echo "$PR_LABELS_JSON" | jq -r '.[].name' | tr '\n' ' ')
19+
3220
if [[ ! "$TARGET_BRANCH" =~ ^"$RELEASE_BRANCH_PREFIX" ]]; then
33-
# Not a release branch, no need for release validation
21+
echo "Not a release branch — skipping release validation."
3422
exit 0
3523
fi
36-
37-
# Check if PR has release label
38-
if [[ ! "$PR_LABELS" =~ "release" ]]; then
24+
25+
if [[ ! "$LABELS" =~ "release" ]]; then
3926
echo "::error::PRs targeting release branches must have the 'release' label"
4027
exit 1
4128
fi
42-
43-
# Extract version from branch name (e.g., v2 from release/v2)
29+
4430
BRANCH_VERSION=$(echo "$TARGET_BRANCH" | sed "s|$RELEASE_BRANCH_PREFIX||")
45-
46-
# Check if trying to merge to an older release branch
31+
4732
if [[ "$BRANCH_VERSION" != "$CURRENT_RELEASE" ]]; then
48-
# Check for special label that allows merging to older releases
49-
if ! [[ "$PR_LABELS" =~ "allow-older-release" ]]; then
33+
if [[ ! "$LABELS" =~ "allow-older-release" ]]; then
5034
echo "::error::Merging to older release branches (release/$BRANCH_VERSION) is not allowed. Current release is $CURRENT_RELEASE."
5135
echo "::error::If this is intentional, add the 'allow-older-release' label to the PR."
5236
exit 1
5337
fi
5438
fi
55-
56-
# Additional validation for release PRs
57-
# Check if PR title follows release format
39+
5840
if ! [[ "$PR_TITLE" =~ ^Release\ \[[0-9]{4}-[0-9]{2}-[0-9]{2}\]$ ]]; then
5941
echo "::error::Release PR title must follow format: 'Release [YYYY-MM-DD]'"
6042
exit 1
6143
fi
62-
63-
# Check if CHANGELOG.md has been updated
44+
6445
if ! git diff --name-only "$BASE_SHA" "$HEAD_SHA" | grep -q "CHANGELOG.md"; then
6546
echo "::error::CHANGELOG.md must be updated for releases"
6647
exit 1
67-
fi
48+
fi

0 commit comments

Comments
 (0)