|
43 | 43 | # Nuget Set Up |
44 | 44 | NUGET_PACKAGES_OUTPUT_PATH: ${{ github.workspace }}/CICDPackageLocation |
45 | 45 | LOCAL_PACKAGES_PATH: ${{ github.workspace }}/CICDPackageLocation |
| 46 | + GITHUB_USERNAME: "Phil-NHS" |
46 | 47 |
|
47 | 48 | # Build Set Up |
48 | 49 | # May need coverlet.collector xplat if using the packaged version to test |
|
79 | 80 | - name: Replace local environment variable in nuget config because cant provide it as a parameter |
80 | 81 | run: | |
81 | 82 | 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 |
82 | 85 | |
83 | 86 | - name: Create appsettings development from secrets |
84 | 87 | run: | |
@@ -139,21 +142,61 @@ jobs: |
139 | 142 | outputs: |
140 | 143 | status: ${{ job.status }} |
141 | 144 | runs-on: ubuntu-latest |
| 145 | + |
| 146 | + |
| 147 | + |
142 | 148 | steps: |
| 149 | + # Checkout so can get access to the file |
| 150 | + - name: Checkout repository |
| 151 | + uses: actions/checkout@v4 |
| 152 | + |
143 | 153 | - name: Validate Branch Name |
144 | 154 | run: | |
| 155 | + |
145 | 156 | #BRANCH_NAME="${GITHUB_HEAD_REF}" |
146 | 157 | BRANCH_NAME="${GITHUB_HEAD_REF:-${GITHUB_REF_NAME}}" |
147 | 158 | echo "Validating branch name: $BRANCH_NAME" |
| 159 | + |
| 160 | + # Read allowed branch patterns from .releaserc.json |
| 161 | + RELEASERC_PATH="${{ github.workspace }}/.releaserc.json" |
| 162 | + echo "Using releaserc at: $RELEASERC_PATH" |
| 163 | + ALLOWED_BRANCHES=$(jq -r '.branches[].name' $RELEASERC_PATH) |
| 164 | +
|
| 165 | + VALID=false |
| 166 | + for pattern in $ALLOWED_BRANCHES; do |
| 167 | + # Convert wildcard * into regex |
| 168 | + REGEX="^${pattern//\*/.*}$" |
| 169 | + if [[ "$BRANCH_NAME" =~ $REGEX ]]; then |
| 170 | + VALID=true |
| 171 | + break |
| 172 | + fi |
| 173 | + done |
| 174 | + |
| 175 | + # Always allow dependabot branches for CI |
| 176 | + # Semver will ignore the branch but will bump the collected dependabot changes branch |
| 177 | + if [[ "$BRANCH_NAME" =~ ^dependabot/ ]]; then |
| 178 | + echo "✅ Branch is a dependabot branch its not for release or versioning but for merging into the dependabot collection branch" |
| 179 | + VALID=true |
| 180 | + fi |
148 | 181 |
|
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 |
| 182 | + if [ "$VALID" = true ]; then |
150 | 183 | echo "✅ Branch name is valid" |
151 | 184 | else |
152 | 185 | 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-*" |
| 186 | + echo "Allowed branch patterns:" |
| 187 | + echo "$ALLOWED_BRANCHES" |
155 | 188 | exit 1 |
156 | 189 | fi |
| 190 | + |
| 191 | + # qqqq drop |
| 192 | + # 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 |
| 193 | + # echo "✅ Branch name is valid" |
| 194 | + # else |
| 195 | + # echo "❌ Invalid branch name: $BRANCH_NAME" |
| 196 | + # echo "Branch names must follow one of the allowed prefixes:" |
| 197 | + # echo " build-*, feat-*, fix-*, bugfix-*, hotfix-*, build-*, chore-*, ci-*, docs-*, perf-*, refactor-*, revert-*, style-*, test-*, sample-*, security-*, config-*, bugfix-*, hotfix-*" |
| 198 | + # exit 1 |
| 199 | + # fi |
157 | 200 |
|
158 | 201 |
|
159 | 202 | reuseable-ci-checks-commitlint: |
@@ -200,6 +243,8 @@ jobs: |
200 | 243 | - name: Replace local environment variable in nuget config because cant provide it as a parameter |
201 | 244 | run: | |
202 | 245 | sed -i "s|%TEL_BLAZOR_PACKAGE_SOURCE%|$LOCAL_PACKAGES_PATH|g" nuget.config |
| 246 | + sed -i "s|%GITHUB_USERNAME%|$GITHUB_USERNAME|g" nuget.config |
| 247 | + sed -i "s|%TEL_GIT_PACKAGES_TOKEN%|$TEL_GIT_PACKAGES_TOKEN|g" nuget.config |
203 | 248 | |
204 | 249 | - name: Clean lock files because the newly generated package file will superseed the locks |
205 | 250 | run: | |
|
0 commit comments