Skip to content

Commit

Permalink
Take 1 new verify branch
Browse files Browse the repository at this point in the history
  • Loading branch information
IanCa committed Jul 26, 2024
1 parent 1a62106 commit 6d9735b
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 11 deletions.
28 changes: 26 additions & 2 deletions .github/workflows/test_get_source_branch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,36 @@ on:
jobs:
print_branch_name:
runs-on: ubuntu-latest
env:
BRANCH_NAME: ${{ github.head_ref }} # Set the BRANCH_NAME environment variable
steps:
- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4
# with:
# ref: ${{ github.head_ref }} # Check out the source branch of the PR

- name: Print source branch name
run: |
echo "The source branch of the PR is: ${{ github.head_ref }}"
echo "The source branch of the PR is: $BRANCH_NAME"
- name: Get latest push changes
id: changed-files
uses: tj-actions/changed-files@v44
with:
since_last_remote_commit: true

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.10'

- name: Install Pre-commit
run: pip install pre-commit

- name: Run pre-commit on changed files
run: |
if [ -n "${{ steps.changed-files.outputs.all_changed_files }}" ]; then
pre-commit run --files ${{ steps.changed-files.outputs.all_changed_files }}
else
echo "No files have changed, skipping pre-commit."
fi
18 changes: 9 additions & 9 deletions scripts/verify_branch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,23 @@ fi
# Echo the branch name and changed files
echo "branch_name: $branch_name"
echo "files: $@"
# Check if the branch name does not start with 'develop-'
if [[ ! "$branch_name" =~ ^develop- ]]; then
echo "This script only processes branches starting with 'develop-'. Exiting..."

branch_prefix=${branch_name%%_*}

# Check if the extracted branch prefix is "admin"
if [[ "$branch_prefix" == "admin" ]]; then
echo "Any changes allowed on admin branches."
exit 0
fi

# Strip 'develop-' from the branch name
branch_name=${branch_name#develop-}

# Verify the branch name is correct after modification
echo "Processed branch_name: $branch_name"
echo "Processed branch_name: branch_prefix"

# Define base file pattern based on branch name
if [[ "$branch_name" == "standard" ]]; then
if [[ "branch_prefix" == "standard" ]]; then
base_pattern="standard_schema/"
else
base_pattern="library_schemas/${branch_name}/"
base_pattern="library_schemas/${branch_prefix}/"
fi

# Define the second pattern by appending 'prerelease' to the base pattern
Expand Down

0 comments on commit 6d9735b

Please sign in to comment.