Created
January 8, 2023 16:59
-
-
Save lkurzyniec/ebbf850a321999f1e6666825b36d89f2 to your computer and use it in GitHub Desktop.
Dependabot Approve and Merg
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: Dependabot Approve and Merg | |
on: pull_request_target | |
permissions: | |
pull-requests: write | |
contents: write | |
issues: write | |
jobs: | |
dependabot: | |
name: Auto approve and merge | |
runs-on: ubuntu-latest | |
if: ${{ github.event.pull_request.user.login == 'dependabot[bot]' }} | |
steps: | |
- name: Fetch update types | |
id: update-types | |
env: | |
UPDATE_TYPES: ${{ secrets.UPDATE_TYPES }} | |
run: | | |
arr=(${UPDATE_TYPES//;/ }) | |
count=${#arr[@]} | |
echo "Types: ${arr[*]}" | |
echo "Count: ${count}" | |
echo "types=${arr[*]}" >> $GITHUB_OUTPUT | |
echo "count=${count}" >> $GITHUB_OUTPUT | |
- name: Fetch Dependabot metadata | |
if: ${{ fromJson(steps.update-types.outputs.count) > 0 }} | |
id: dependabot-metadata | |
uses: dependabot/[email protected] | |
- name: Approve and merge | |
id: auto-merge | |
if: ${{ fromJson(steps.update-types.outputs.count) > 0 && contains(steps.update-types.outputs.types, steps.dependabot-metadata.outputs.update-type) }} | |
run: | | |
gh pr edit "$PR_URL" --add-label "auto-merged" | |
gh pr review --approve "$PR_URL" | |
gh pr merge --auto --squash "$PR_URL" | |
echo "STATUS=true" >> $GITHUB_OUTPUT | |
env: | |
PR_URL: ${{ github.event.pull_request.html_url }} | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Write summary | |
run: | | |
result="skip. :x:" | |
if [ "${STATUS}" == "true" ]; then | |
result=" auto-merge! :white_check_mark:" | |
fi | |
echo "### Done with ${result}" >> $GITHUB_STEP_SUMMARY | |
env: | |
STATUS: ${{ steps.auto-merge.outputs.STATUS }} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment