This repository has been archived by the owner on Jan 14, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 109
53 lines (43 loc) · 1.65 KB
/
updateDependabot.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
name: Update Dependabot config
on:
workflow_dispatch:
env:
BRANCH_NAME: "dependabot/update-config-${{ github.run_id }}"
jobs:
UpdateDependabot:
name: 'Update Dependabot'
runs-on: ubuntu-latest
permissions:
actions: read
pull-requests: write
contents: write
steps:
- uses: actions/checkout@v4
- name: 'Create a working branch'
run: |
git checkout -b ${{ env.BRANCH_NAME }}
- name: 'Update Dependabot'
shell: pwsh
run: |
./.github/scripts/update-dependabot.ps1 -targetBranch component-updates -outputFile ./.github/dependabot.yml
- name: 'Push files to repo'
shell: pwsh
run: |
# Set the name on the commits as it will appear in Github
git config --global user.name 'Github Action'
git config --global user.email '[email protected]'
git add ./.github/dependabot.yml
# Get the name of the commit that triggered the workflow,
# so we can refer to it in our automated commit message.
$message = git log -1 --pretty=format:"%s"
# Only commit if there are changes to commit, otherwise commit will throw an error.
if(git status -uno --short) {
git commit -m "Auto update: $message"
git push --set-upstream origin ${{ env.BRANCH_NAME }}
gh pr create --title "Dependabot config update" --body "The dependabot.yaml file was updated and needs to be merged to main."
}
else {
Write-Output "No changes to commit. Bye."
}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}