Skip to content

Commit

Permalink
Branch name limit to 20 characters (#139823)
Browse files Browse the repository at this point in the history
  • Loading branch information
britt-mo authored Nov 15, 2024
1 parent b7e2c23 commit 0869971
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 8 deletions.
5 changes: 3 additions & 2 deletions .github/branchNameValidation.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
set -e

local_branch=${1}
[ -z "${1}" ] && local_branch=$(git rev-parse --abbrev-ref HEAD)

valid_branch='^[a-z][a-z0-9-]*$'

Expand All @@ -15,7 +16,7 @@ join_by() { local IFS='|'; echo "$*"; }
#creates glob match to check for reserved words used in branch names which would trigger failures
glob=$(join_by $(for i in ${reserved_words[@]}; do echo "^$i-|-$i$|-$i-|^$i$"; done;))

if [[ ! $local_branch =~ $valid_branch ]] || [[ $local_branch =~ $glob ]] || [[ ${#local_branch} -gt 64 ]]; then
if [[ ! $local_branch =~ $valid_branch ]] || [[ $local_branch =~ $glob ]] || [[ ${#local_branch} -gt 20 ]]; then
echo """
------------------------------------------------------------------------------------------------------------------------------
ERROR: Please read below
Expand All @@ -28,7 +29,7 @@ if [[ ! $local_branch =~ $valid_branch ]] || [[ $local_branch =~ $glob ]] || [[
Therefore, the branch name must be a valid service name. Branch name must be all lower case with no spaces and no underscores.
From Serverless:
A service name should only contain alphanumeric (case sensitive) and hyphens. It should start with an alphabetic character and shouldnt exceed 128 characters.
A service name should only contain alphanumeric (case sensitive) and hyphens. It should start with an alphabetic character and shouldnt exceed 20 characters.
For Github Actions support, please push your code to a new branch with a name that meets Serverless' service name requirements.
So, make a new branch with a name that begins with a letter and is made up of only letters, numbers, and hyphens... then delete this branch.
------------------------------------------------------------------------------------------------------------------------------
Expand Down
5 changes: 2 additions & 3 deletions .github/workflows/pr-notification.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ permissions:
contents: write
issues: write
pull-requests: write

jobs:
endpoint:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -40,15 +39,15 @@ jobs:
application_endpoint_url="endpoint not found"
fi
echo "application_endpoint_url=$application_endpoint_url" >> $GITHUB_OUTPUT
outputs:
application_endpoint_url: ${{ steps.getendpoint.outputs.application_endpoint_url }}

notify_integrations_channel:
runs-on: ubuntu-latest
needs:
- endpoint
# avoiding notifications for automated Snyk Pull Requests and draft pull requests
# avoiding notifications for automated Snyk Pull Requests and draft pull requests
if: github.actor != 'mdct-github-service-account' && !github.event.pull_request.draft
steps:
- name: Slack Notification
Expand Down
12 changes: 11 additions & 1 deletion .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,17 @@ name: Pull-request
on: [pull_request]

jobs:
prchecks:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.10"
- name: Configure pre-commit to skip branch name validation
run: |
echo "SKIP=branch-name-validation" >> $GITHUB_ENV
- uses: pre-commit/[email protected]
linting:
runs-on: ubuntu-latest
steps:
Expand All @@ -11,7 +22,6 @@ jobs:
uses: actions/setup-python@v4
with:
python-version: "3.10"
- uses: pre-commit/[email protected]
jest-frontend:
runs-on: ubuntu-latest
steps:
Expand Down
11 changes: 9 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
exclude: 'seed-section-base-*'
exclude: "seed-section-base-*"
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.0.1
Expand Down Expand Up @@ -38,4 +38,11 @@ repos:
- repo: https://github.com/zricethezav/gitleaks
rev: v8.12.0
hooks:
- id: gitleaks
- id: gitleaks
- repo: local
hooks:
- id: branch-name-validation
name: branch-name-validation
entry: .github/branchNameValidation.sh
language: script
pass_filenames: false

0 comments on commit 0869971

Please sign in to comment.