4343 # Nuget Set Up
4444 NUGET_PACKAGES_OUTPUT_PATH : ${{ github.workspace }}/CICDPackageLocation
4545 LOCAL_PACKAGES_PATH : ${{ github.workspace }}/CICDPackageLocation
46+ GITHUB_USERNAME : " Phil-NHS"
4647
4748 # Build Set Up
4849 # May need coverlet.collector xplat if using the packaged version to test
7980 - name : Replace local environment variable in nuget config because cant provide it as a parameter
8081 run : |
8182 sed -i "s|%TEL_BLAZOR_PACKAGE_SOURCE%|$LOCAL_PACKAGES_PATH|g" nuget.config
83+ sed -i "s|%GITHUB_USERNAME%|$GITHUB_USERNAME|g" nuget.config
84+ sed -i "s|%TEL_GIT_PACKAGES_TOKEN%|$TEL_GIT_PACKAGES_TOKEN|g" nuget.config
8285
8386 - name : Create appsettings development from secrets
8487 run : |
@@ -139,21 +142,59 @@ jobs:
139142 outputs :
140143 status : ${{ job.status }}
141144 runs-on : ubuntu-latest
145+
142146 steps :
147+ # Checkout so can get access to the file
148+ - name : Checkout repository
149+ uses : actions/checkout@v4
150+
143151 - name : Validate Branch Name
144152 run : |
153+
145154 #BRANCH_NAME="${GITHUB_HEAD_REF}"
146155 BRANCH_NAME="${GITHUB_HEAD_REF:-${GITHUB_REF_NAME}}"
147156 echo "Validating branch name: $BRANCH_NAME"
157+
158+ # Read allowed branch patterns from .releaserc.json
159+ RELEASERC_PATH="${{ github.workspace }}/.releaserc.json"
160+ echo "Using releaserc at: $RELEASERC_PATH"
161+ ALLOWED_BRANCHES=$(jq -r '.branches[].name' $RELEASERC_PATH)
162+
163+ VALID=false
164+ for pattern in $ALLOWED_BRANCHES; do
165+ # Convert wildcard * into regex
166+ REGEX="^${pattern//\*/.*}$"
167+ if [[ "$BRANCH_NAME" =~ $REGEX ]]; then
168+ VALID=true
169+ break
170+ fi
171+ done
172+
173+ # Always allow dependabot branches for CI
174+ # Semver will ignore the branch but will bump the collected dependabot changes branch
175+ if [[ "$BRANCH_NAME" =~ ^dependabot/ ]]; then
176+ echo "✅ Branch is a dependabot branch its not for release or versioning but for merging into the dependabot collection branch"
177+ VALID=true
178+ fi
148179
149- if [[ "$BRANCH_NAME " =~ ^(build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test|sample|security|config|bugfix|hotfix)-[a-zA-Z0-9._/-]+$ ]] || [[ "$BRANCH_NAME" == "master" ] ]; then
180+ if [ "$VALID " = true ]; then
150181 echo "✅ Branch name is valid"
151182 else
152183 echo "❌ Invalid branch name: $BRANCH_NAME"
153- echo "Branch names must follow one of the allowed prefixes :"
154- echo " build-*, feat-*, fix-*, bugfix-*, hotfix-*, build-*, chore-*, ci-*, docs-*, perf-*, refactor-*, revert-*, style-*, test-*, sample-*, security-*, config-*, bugfix-*, hotfix-* "
184+ echo "Allowed branch patterns :"
185+ echo "$ALLOWED_BRANCHES "
155186 exit 1
156187 fi
188+
189+ # qqqq drop
190+ # if [[ "$BRANCH_NAME" =~ ^(build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test|sample|security|config|bugfix|hotfix)-[a-zA-Z0-9._/-]+$ ]] || [[ "$BRANCH_NAME" == "master" ]]; then
191+ # echo "✅ Branch name is valid"
192+ # else
193+ # echo "❌ Invalid branch name: $BRANCH_NAME"
194+ # echo "Branch names must follow one of the allowed prefixes:"
195+ # echo " build-*, feat-*, fix-*, bugfix-*, hotfix-*, build-*, chore-*, ci-*, docs-*, perf-*, refactor-*, revert-*, style-*, test-*, sample-*, security-*, config-*, bugfix-*, hotfix-*"
196+ # exit 1
197+ # fi
157198
158199
159200 reuseable-ci-checks-commitlint :
@@ -164,11 +205,24 @@ jobs:
164205 outputs :
165206 status : ${{ job.status }}
166207 steps :
167- - uses : actions/checkout@v4
208+ - name : Checkout repository
209+ uses : actions/checkout@v4
168210 with :
169211 fetch-depth : 0
170-
171- - uses : wagoid/commitlint-github-action@v5
212+
213+ - name : Check branch and run commitlint
214+ run : |
215+ BRANCH_NAME="${GITHUB_HEAD_REF:-${GITHUB_REF_NAME}}"
216+ echo "Branch name: $BRANCH_NAME"
217+ if [[ "$BRANCH_NAME" =~ ^dependabot/ ]]; then
218+ echo "✅ Branch is a dependabot branch - skipping commitlint"
219+ exit 0
220+ else
221+ echo "Regular branch - will run commitlint in next step"
222+ fi
223+
224+ - name : Run commitlint action
225+ uses : wagoid/commitlint-github-action@v5
172226 with :
173227 configFile : .commitlintrc.json
174228 # Only set from/to if inputs are provided, otherwise let action use defaults
@@ -200,6 +254,8 @@ jobs:
200254 - name : Replace local environment variable in nuget config because cant provide it as a parameter
201255 run : |
202256 sed -i "s|%TEL_BLAZOR_PACKAGE_SOURCE%|$LOCAL_PACKAGES_PATH|g" nuget.config
257+ sed -i "s|%GITHUB_USERNAME%|$GITHUB_USERNAME|g" nuget.config
258+ sed -i "s|%TEL_GIT_PACKAGES_TOKEN%|$TEL_GIT_PACKAGES_TOKEN|g" nuget.config
203259
204260 - name : Clean lock files because the newly generated package file will superseed the locks
205261 run : |
0 commit comments