Update Dependabot config #26
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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@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 '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 }} |