-
Notifications
You must be signed in to change notification settings - Fork 102
48 lines (38 loc) · 1.53 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
name: Update Dependabot config
on:
workflow_dispatch:
env:
BRANCH_NAME: "dependabot/update-config-${{ github.run_id }}"
jobs:
UpdateDependabot:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- 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 'alwayson@users.noreply.github.com'
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 }}