Merge bot #1
Workflow file for this run
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
############################################################################### | |
# _ _ _ _ _____ _ | |
# | | | | | | | | | __ \(_) | |
# | | ___ | |__ _ __ | |_| |__ ___ | |__) |_ _ __ _ __ ___ _ __ | |
# _ | |/ _ \| '_ \| '_ \ | __| '_ \ / _ \ | _ /| | '_ \| '_ \ / _ \ '__| | |
# | |__| | (_) | | | | | | | | |_| | | | __/ | | \ \| | |_) | |_) | __/ | | |
# \____/ \___/|_| |_|_| |_| \__|_| |_|\___| |_| \_\_| .__/| .__/ \___|_| | |
# | | | | | |
# |_| |_| | |
# | |
# Copyright (c) 2024 Claudio André <[email protected]> | |
# | |
# This program comes with ABSOLUTELY NO WARRANTY; express or implied. | |
# | |
# This program is free software: you can redistribute it and/or modify | |
# it under the terms of the GNU General Public License as published by | |
# the Free Software Foundation, as expressed in version 2, seen at | |
# http://www.gnu.org/licenses/gpl-2.0.html | |
############################################################################### | |
# GitHub Action to automatically merge PRs | |
# More info at https://github.com/openwall/john-packages | |
--- | |
name: Merge bot | |
"on": | |
pull_request_review: | |
types: | |
- submitted | |
permissions: | |
contents: read | |
jobs: | |
merge-bot: | |
runs-on: ubuntu-latest | |
name: merge-bot | |
permissions: | |
contents: write | |
pull-requests: write | |
if: github.actor == 'claudioandre-br' || github.actor == 'solardiz' | |
steps: | |
- name: Harden Runner | |
uses: step-security/harden-runner@91182cccc01eb5e619899d80e4e971d6181294a7 # v2.10.1 | |
with: | |
disable-sudo: true | |
egress-policy: block | |
allowed-endpoints: > | |
api.github.com:443 | |
github.com:443 | |
raw.githubusercontent.com:443 | |
- name: GitHub context | |
env: | |
GITHUB_CONTEXT: ${{ toJSON(github) }} | |
run: echo "$GITHUB_CONTEXT" | |
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
with: | |
fetch-depth: 0 | |
ref: main | |
- name: Auto-merge PRs | |
run: | | |
if [[ "$REQUEST" != "bot: MERGE"* ]]; then | |
echo "There is no need for a merge! Nothing to do." | |
exit 0 | |
fi | |
if [[ "$REQUEST" == "bot: MERGE skip" ]]; then | |
echo "Do not perform workflow validation." | |
echo "All GitHub rules still apply." | |
SKIP="true" | |
fi | |
gh pr checkout "$PR_URL" | |
DATA="$(gh pr status --json latestReviews --jq '.currentBranch.latestReviews[].state == "APPROVED"')" | |
APPROVALS="$(echo "$DATA" | grep -c 'true' || true)" | |
echo "Approvals: $APPROVALS" | |
# Set up the merge-procedures.sh | |
export APPROVALS | |
export SKIP | |
wget https://raw.githubusercontent.com/openwall/john-packages/release/scripts/merge_procedures.sh -O merge-procedures.sh | |
source merge-procedures.sh | |
env: | |
GH_TOKEN: ${{ github.token }} | |
PR_URL: ${{ github.event.pull_request.html_url }} | |
BRANCH: ${{ github.event.pull_request.head.ref }} | |
OWNER: ${{ github.event.pull_request.head.repo.owner.login }} | |
REPO: ${{ github.event.pull_request.head.repo.name }} | |
REQUEST: ${{ github.event.review.body }} |