Skip to content

Commit 7fc3e11

Browse files
authored
Merge pull request #223 from TechnologyEnhancedLearning/master
make sure up to date
2 parents 5aeb983 + 09b04b3 commit 7fc3e11

10 files changed

+175
-66
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# This script seperate major and minor but we do merge them into the same branch.
2+
# Having two steps allows us to easily turn off major changes in future and then script them to their own branch and pipeline.
3+
name: Auto-merge Dependabot PRs into collected branch
4+
on:
5+
pull_request:
6+
types: [opened, synchronize]
7+
branches: [Automatic_version_update_dependabot] # Make sure this matches your actual branch name
8+
9+
permissions:
10+
contents: write
11+
pull-requests: write
12+
13+
jobs:
14+
auto-merge:
15+
runs-on: ubuntu-latest
16+
if: github.actor == 'dependabot[bot]'
17+
steps:
18+
- name: Extract update type
19+
id: extract
20+
run: |
21+
PR_TITLE="${{ github.event.pull_request.title }}"
22+
if [[ $PR_TITLE == *"(major)"* ]]; then
23+
echo "update_type=major" >> $GITHUB_OUTPUT
24+
else
25+
echo "update_type=minor_or_patch" >> $GITHUB_OUTPUT
26+
fi
27+
28+
- name: Auto-merge minor and patch updates
29+
if: steps.extract.outputs.update_type == 'minor_or_patch'
30+
run: gh pr merge --auto --squash "${{ github.event.pull_request.html_url }}"
31+
env:
32+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
33+
34+
- name: Auto-merge major updates
35+
if: steps.extract.outputs.update_type == 'major'
36+
run: gh pr merge --auto --squash "${{ github.event.pull_request.html_url }}"
37+
env:
38+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/automerge-passing-minor-patch-dependabot-prs.yml

Lines changed: 0 additions & 59 deletions
This file was deleted.
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: Collected Dependabot Promotion From Staging To Master
2+
on:
3+
schedule:
4+
# we want the opposite weeks to staging so we get a week where it occurs in manual testing
5+
- cron: '0 9 8-14 * 1' # Second Monday of month
6+
- cron: '0 9 22-28 * 1' # Fourth Monday of month
7+
workflow_dispatch:
8+
9+
jobs:
10+
promote-to-master:
11+
runs-on: ubuntu-latest
12+
permissions:
13+
contents: write
14+
pull-requests: write
15+
steps:
16+
- name: Checkout
17+
uses: actions/checkout@v4
18+
with:
19+
fetch-depth: 0
20+
21+
- name: Check for changes
22+
id: changes
23+
run: |
24+
git fetch origin Automatic_collected_dependabot_staging:Automatic_collected_dependabot_staging
25+
git fetch origin master:master # or main/master - whatever your prod branch is
26+
27+
if git diff --quiet master Automatic_collected_dependabot_staging; then
28+
echo "has_changes=false" >> $GITHUB_OUTPUT
29+
else
30+
echo "has_changes=true" >> $GITHUB_OUTPUT
31+
fi
32+
33+
- name: Create PR to master
34+
if: steps.changes.outputs.has_changes == 'true'
35+
run: |
36+
if gh pr list --head Automatic_collected_dependabot_staging --base master --json number --jq '.[0].number' | grep -q .; then
37+
echo "PR already exists, skipping creation"
38+
else
39+
gh pr create \
40+
--base master \
41+
--head Automatic_collected_dependabot_staging \
42+
--title "Fortnightly dependabot collected master promotion - $(date +%Y-%m-%d)" \
43+
--body "Automated weekly promotion from staging to master after testing period" \
44+
--auto-merge \
45+
--merge
46+
fi
47+
env:
48+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: Dependabot Collected Promotion To Staging
2+
# this logic will require branch ruleset checks of running the dev pipeline
3+
on:
4+
schedule:
5+
# Promotion from staging to release should be a week apart so alternating weeks (also live updates dangerous)
6+
- cron: '0 9 1-7 * 1' # First Monday of month
7+
- cron: '0 9 15-21 * 1' # Third Monday of month
8+
workflow_dispatch: # Allow manual trigger
9+
10+
jobs:
11+
promote-to-automatic-collected-dependabot-staging:
12+
runs-on: ubuntu-latest
13+
permissions:
14+
contents: write
15+
pull-requests: write
16+
steps:
17+
- name: Checkout
18+
uses: actions/checkout@v4
19+
with:
20+
fetch-depth: 0
21+
22+
- name: Check for changes
23+
id: changes
24+
run: |
25+
git fetch origin Automatic_version_update_dependabot:Automatic_version_update_dependabot
26+
git fetch origin Automatic_collected_dependabot_staging:Automatic_collected_dependabot_staging
27+
28+
if git diff --quiet Automatic_collected_dependabot_staging Automatic_version_update_dependabot; then
29+
echo "has_changes=false" >> $GITHUB_OUTPUT
30+
else
31+
echo "has_changes=true" >> $GITHUB_OUTPUT
32+
fi
33+
34+
- name: Create PR to Automatic_collected_dependabot_staging
35+
if: steps.changes.outputs.has_changes == 'true'
36+
run: |
37+
gh pr create \
38+
--base Automatic_collected_dependabot_staging \
39+
--head Automatic_version_update_dependabot \
40+
--title "Fortnightly dependabot collected to staging - $(date +%Y-%m-%d)" \
41+
--body "Automated Fortnightly promotion of dependency updates from dependabot" \
42+
--auto-merge \
43+
--merge
44+
env:
45+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/dev.yml

Lines changed: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ on:
44
branches-ignore:
55
- 'main'
66
- 'master'
7+
# We currently dont intend to test the showcase per package bump so wont run for package bumps
8+
# we will run on the collected bumps merging though
9+
- 'dependabot/**'
10+
711
workflow_dispatch:
812

913
permissions:
@@ -83,15 +87,40 @@ jobs:
8387
echo "Semantic Release packages installed."
8488
npm ls --depth=0 # Debug: List installed packages
8589
86-
#configured with .releaseserc
90+
# Configured with .releaseserc
8791
# Dry run we are not versioning the repo
8892
- name: Run dev semantic version (None Blocking)
8993
id: detect_semantic_version
9094
run: |
95+
echo "error catch run of semver first to get any error detail on config issues"
96+
set +e
97+
SEMVER_OUTPUT_RAW_ERROR_CHECK=$(npx semantic-release --dry-run 2> /tmp/semantic-release-errors.log)
98+
STATUS_ERROR_CHECK=$?
99+
100+
# Now you can check the status and log the error messages if an error occurred
101+
if [ $STATUS_ERROR_CHECK -ne 0 ]; then
102+
echo "❌ Semantic release failed with exit code $STATUS_ERROR_CHECK."
103+
echo "❌ Error output:"
104+
cat /tmp/semantic-release-errors.log
105+
else
106+
echo "✅ Semantic Ouput success : $SEMVER_OUTPUT_RAW_ERROR_CHECK "
107+
echo "✅ Error on success : $STATUS_ERROR_CHECK"
108+
fi
109+
110+
set -e
111+
91112
92113
echo "running semantic-release"
93-
SEMVER_OUTPUT_RAW=$(npx semantic-release --dry-run 2>&1)
94-
STATUS=$?
114+
semver_output_raw=$(npx semantic-release --dry-run 2>&1)
115+
status=$?
116+
117+
# Now you can check the status and log the error messages if an error occurred
118+
if [ $STATUS -ne 0 ]; then
119+
echo "Semantic release failed with exit code $STATUS."
120+
echo "Error output:"
121+
cat /tmp/semantic-release-errors.log
122+
fi
123+
95124
echo "status = $STATUS"
96125
echo "$SEMVER_OUTPUT_RAW"
97126
@@ -357,5 +386,4 @@ jobs:
357386
-H "Authorization: Bearer $TEL_GIT_PACKAGES_TOKEN" \
358387
-H "X-GitHub-Api-Version: 2022-11-28" \
359388
https://api.github.com/repos/$repo_owner/$repo_name/dispatches \
360-
-d "{\"event_type\": \"$event_type\", \"client_payload\": {\"artifact_url\": \"$artifact_url\"}}"
361-
389+
-d "{\"event_type\": \"$event_type\", \"client_payload\": {\"artifact_url\": \"$artifact_url\"}}"

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ jobs:
202202
run: |
203203
BRANCH_NAME="${GITHUB_HEAD_REF:-${GITHUB_REF_NAME}}"
204204
echo "Branch name: $BRANCH_NAME"
205-
if [[ "$BRANCH_NAME" =~ ^dependabot/ ]]; then
205+
if [[ "$BRANCH_NAME" =~ ^dependabot/ ]] || [[ "$AUTHOR_NAME" == "dependabot[bot]" ]] || [[ "$COMMIT_MSG" =~ ^Bump ]]; then
206206
echo "✅ Branch is a dependabot branch - skipping commitlint ✅"
207207
echo "skip=true" >> $GITHUB_OUTPUT
208208
else

.github/workflows/workflow-readme.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,10 @@ The individual steps also automatically pass so can see if any error at the end
8181
# Notes
8282
- doesnt run easily with nektos act due to git ref checks and calling other workflows
8383
- for tests use the run-tests-and-report-with-env-values.ps1 file
84-
84+
- dependabot duplicates tokens using dependabot secrets including write so can run checks
85+
- autoverging is being tried for major and minor
86+
- branch checks must pass for merge on automated_version
87+
- checks required but overrideable for all workflows
8588
## Versioning
8689
Via semantic release and recorded as a generate c# file used by a blazor component
8790

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,3 +236,4 @@ TELBlazor.Components.ShowCase.E2ETests.WasmServerHost/Logs/*
236236

237237
# Generated version info files
238238
TELBlazor.Components/TELBlazorPackageVersion/VersionInfo*.cs
239+
/.github/workflows/test.yml

.releaserc.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66
{
77
"name": "Automatic_version_update_dependabot"
88
},
9+
{
10+
"name": "Automatic_collected_dependabot_staging",
11+
"prerelease": "dependabot-staging"
12+
},
913
{
1014
"name": "feat-*",
1115
"prerelease": true

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ the ability to produce static prerendered html. The prerendered html is written
7474
- enter the variable names and variable values as follows:
7575
- GITHUB_USERNAME / [Your GitHub username]
7676
- TEL_GIT_PACKAGES_TOKEN / [The copied token]
77+
- LOCAL_PACKAGES_PATH / [Path to your local packages folder]
7778
- then select **OK**
7879
- select **OK** again to close all dialogs.
7980
- **Restore Nuget, Npm, Tooling, playwright and build:**

0 commit comments

Comments
 (0)