Skip to content

Commit 220c13a

Browse files
authored
Merge pull request #184 from TechnologyEnhancedLearning/ci-dependabot-setup
Ci dependabot setup
2 parents b135b5e + eff7705 commit 220c13a

File tree

2 files changed

+63
-2
lines changed

2 files changed

+63
-2
lines changed

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,12 +203,14 @@ jobs:
203203
echo "Branch name: $BRANCH_NAME"
204204
if [[ "$BRANCH_NAME" =~ ^dependabot/ ]]; then
205205
echo "✅ Branch is a dependabot branch - skipping commitlint"
206-
exit 0
206+
echo "skip=true" >> $GITHUB_OUTPUT
207207
else
208208
echo "Regular branch - will run commitlint in next step"
209+
echo "skip=false" >> $GITHUB_OUTPUT
209210
fi
210211
211-
- name: Run commitlint action
212+
- name: Run commitlint actio
213+
if: steps.check-branch.outputs.skip != 'true'
212214
uses: wagoid/commitlint-github-action@v5
213215
with:
214216
configFile: .commitlintrc.json

.github/workflows/workflow-readme.md

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,3 +84,62 @@ The individual steps also automatically pass so can see if any error at the end
8484

8585
## Versioning
8686
Via semantic release and recorded as a generate c# file used by a blazor component
87+
88+
## Alternative Approaches
89+
90+
```
91+
name: Pull Request Checks
92+
93+
# ⚠️ pull_request_target is dangerous it allows secrets to be used by forks and bots, ⚠️
94+
# ⚠️ we want dependabot only to be using these secrets so addition logic requires an "if" for every job ⚠️
95+
# We will restrict it by making pull_request_target only for the Automatic_version_update_dependabot and then use
96+
# an if to ensure its only by dependabot
97+
98+
on:
99+
pull_request:
100+
branches: ['**'] # Run on all branches
101+
branches-ignore: ['dependabot/**'] # Skip Dependabot PRs
102+
pull_request_target:
103+
branches: ['Automatic_version_update_dependabot'] # Base branch for Dependabot PRs
104+
workflow_dispatch:
105+
106+
jobs:
107+
dummy:
108+
if: |
109+
(github.actor == 'dependabot[bot]' &&
110+
startsWith(github.head_ref, 'dependabot/') &&
111+
github.event_name == 'pull_request_target')
112+
||
113+
(github.actor != 'dependabot[bot]' && github.event_name == 'pull_request')
114+
runs-on: ubuntu-latest
115+
steps:
116+
- name: Dummy Step
117+
run: echo "This is a dummy job to allow workflow_dispatch"
118+
119+
pull-request-call-reusable-ci-checks-workflow:
120+
if: |
121+
(github.actor == 'dependabot[bot]' &&
122+
startsWith(github.head_ref, 'dependabot/') &&
123+
github.event_name == 'pull_request_target')
124+
||
125+
(github.actor != 'dependabot[bot]' && github.event_name == 'pull_request')
126+
name: Pull Request run CI Checks
127+
uses: ./.github/workflows/reuseable-ci-checks.yml
128+
needs: dummy
129+
with:
130+
runall: true
131+
132+
# could try secrets:inherit QQQQ
133+
secrets:
134+
UNITTESTS_APPSETTINGS_DEVELOPMENT: ${{ secrets.UNITTESTS_APPSETTINGS_DEVELOPMENT }}
135+
WASMSTATICCLIENT_APPSETTINGS_DEVELOPMENT: ${{ secrets.WASMSTATICCLIENT_APPSETTINGS_DEVELOPMENT }}
136+
WASMSERVERHOSTCLIENT_APPSETTINGS_DEVELOPMENT: ${{ secrets.WASMSERVERHOSTCLIENT_APPSETTINGS_DEVELOPMENT }}
137+
WASMSERVERHOST_APPSETTINGS_DEVELOPMENT: ${{ secrets.WASMSERVERHOST_APPSETTINGS_DEVELOPMENT }}
138+
TEL_GIT_PACKAGES_TOKEN: ${{secrets.NUGETKEY }}
139+
140+
UNITTESTS_APPSETTINGS_PRODUCTION: ${{ secrets.UNITTESTS_APPSETTINGS_PRODUCTION }}
141+
WASMSTATICCLIENT_APPSETTINGS_PRODUCTION: ${{ secrets.WASMSTATICCLIENT_APPSETTINGS_PRODUCTION }}
142+
WASMSERVERHOSTCLIENT_APPSETTINGS_PRODUCTION: ${{ secrets.WASMSERVERHOSTCLIENT_APPSETTINGS_PRODUCTION }}
143+
WASMSERVERHOST_APPSETTINGS_PRODUCTION: ${{ secrets.WASMSERVERHOST_APPSETTINGS_PRODUCTION }}
144+
145+
```

0 commit comments

Comments
 (0)