Skip to content

deps: bump serde_json from 1.0.137 to 1.0.138 in the serde group #96

deps: bump serde_json from 1.0.137 to 1.0.138 in the serde group

deps: bump serde_json from 1.0.137 to 1.0.138 in the serde group #96

name: Auto Merge Dependabot PRs
on:
pull_request:
types:
- opened
- synchronize
- reopened
jobs:
evaluate-auto-merge-conditions:
runs-on: ubuntu-latest
outputs:
should_auto_merge: ${{ steps.determine-eligibility.outputs.should_auto_merge }}
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.ref }} # This is necessary for this job to be able to get the correct commit message from `git log`
- name: Evaluate auto-merge eligibility
id: determine-eligibility
run: |
IS_DEPENDABOT_ACTOR="${{ github.actor == 'dependabot[bot]' }}"
IS_LASTMJS_ACTOR="${{ github.actor == 'lastmjs' }}"
HAS_DEPENDENCIES_LABEL="${{ contains(github.event.pull_request.labels.*.name, 'dependencies') }}"
COMMIT_MESSAGE=$(git log -1 --pretty=format:"%s")
IS_TEMPLATE_UPDATE_COMMIT="false"
if [[ "$COMMIT_MESSAGE" == "chore: update templates for dependency changes" ]]; then
IS_TEMPLATE_UPDATE_COMMIT="true"
fi
IS_STANDARD_DEPENDABOT_PR="false"
if [[ "$HAS_DEPENDENCIES_LABEL" == "true" && "$IS_DEPENDABOT_ACTOR" == "true" ]]; then
IS_STANDARD_DEPENDABOT_PR="true"
fi
HAS_TEMPLATE_UPDATE="false"
if [[ "$HAS_DEPENDENCIES_LABEL" == "true" && "$IS_LASTMJS_ACTOR" == "true" && "$IS_TEMPLATE_UPDATE_COMMIT" == "true" ]]; then
HAS_TEMPLATE_UPDATE="true"
fi
SHOULD_AUTO_MERGE="false"
if [[ $IS_STANDARD_DEPENDABOT_PR == "true" || $HAS_TEMPLATE_UPDATE == "true" ]]; then
SHOULD_AUTO_MERGE="true"
fi
# Add logging here where variables are in scope
echo "Commit message: $COMMIT_MESSAGE"
echo "Actor: ${{ github.actor }}"
echo "Is template update commit: $IS_TEMPLATE_UPDATE_COMMIT"
echo "Has dependencies label: $HAS_DEPENDENCIES_LABEL"
echo "Is lastmjs actor: $IS_LASTMJS_ACTOR"
echo "Is dependabot actor: $IS_DEPENDABOT_ACTOR"
echo "Is standard dependabot PR: $IS_STANDARD_DEPENDABOT_PR"
echo "Has template update: $HAS_TEMPLATE_UPDATE"
echo "Should auto merge: $SHOULD_AUTO_MERGE"
echo "should_auto_merge=$SHOULD_AUTO_MERGE" >> $GITHUB_OUTPUT
perform-auto-merge:
needs: evaluate-auto-merge-conditions
if: ${{ needs.evaluate-auto-merge-conditions.outputs.should_auto_merge == 'true' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.ref }}
token: ${{ secrets.LASTMJS_GITHUB_TOKEN }}
- name: Approve dependency update PR
run: gh pr review --approve "$PR_NUMBER"
env:
PR_NUMBER: ${{ github.event.pull_request.number }}
GITHUB_TOKEN: ${{ secrets.LASTMJS_GITHUB_TOKEN }}
- name: Merge dependency update PR
run: |
gh pr merge "$PR_NUMBER" \
--merge \
--auto
env:
PR_NUMBER: ${{ github.event.pull_request.number }}
GITHUB_TOKEN: ${{ secrets.LASTMJS_GITHUB_TOKEN }}