Skip to content

Commit 31d9731

Browse files
authored
Merge pull request #123 from TechnologyEnhancedLearning/ci-dependabot-setup
Ci dependabot setup
2 parents d728264 + b17b8a8 commit 31d9731

File tree

2 files changed

+50
-5
lines changed

2 files changed

+50
-5
lines changed

.github/dependabot.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ updates:
66
interval: "daily"
77
open-pull-requests-limit: 100
88
target-branch: "Automatic_version_update_dependabot"
9+
rebase-strategy: "auto"
910

1011
- package-ecosystem: "npm"
1112
directory: "/"
1213
schedule:
1314
interval: "daily"
1415
open-pull-requests-limit: 100
1516
target-branch: "Automatic_version_update_dependabot"
16-
17-
17+
rebase-strategy: "auto"

.github/workflows/reuseable-ci-checks.yml

Lines changed: 48 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ env:
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
@@ -79,6 +80,8 @@ jobs:
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,61 @@ jobs:
139142
outputs:
140143
status: ${{ job.status }}
141144
runs-on: ubuntu-latest
145+
146+
147+
142148
steps:
149+
# Checkout so can get access to the file
150+
- name: Checkout repository
151+
uses: actions/checkout@v4
152+
143153
- name: Validate Branch Name
144154
run: |
155+
145156
#BRANCH_NAME="${GITHUB_HEAD_REF}"
146157
BRANCH_NAME="${GITHUB_HEAD_REF:-${GITHUB_REF_NAME}}"
147158
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
148181
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
150183
echo "✅ Branch name is valid"
151184
else
152185
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"
155188
exit 1
156189
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
157200

158201

159202
reuseable-ci-checks-commitlint:
@@ -200,6 +243,8 @@ jobs:
200243
- name: Replace local environment variable in nuget config because cant provide it as a parameter
201244
run: |
202245
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
203248
204249
- name: Clean lock files because the newly generated package file will superseed the locks
205250
run: |

0 commit comments

Comments
 (0)