Skip to content

Instantly share code, notes, and snippets.

@heoelri
Created January 7, 2022 10:18
Show Gist options
  • Save heoelri/2f05a3bcb6da4991c3432b77e60d833d to your computer and use it in GitHub Desktop.
Save heoelri/2f05a3bcb6da4991c3432b77e60d833d to your computer and use it in GitHub Desktop.
updateDependabot.yml GitHub Actions workflow executing update-dependabot.ps1
name: Update Dependabot config
on: push
jobs:
UpdateDependabot:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- 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 origin
}
else {
Write-Output "No changes to commit. Bye."
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment