Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

APP-211: Streamline Bulk Approval Implementation #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 55 additions & 0 deletions .github/workflows/streamline-approval-workflow.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Streamline-Approve

on:
pull_request:
branches: ["master", "main"]

jobs:
run-streamlined-approval:
if: github.event.pull_request.user.login == 'hs-pr-bot'
runs-on: ubuntu-latest
steps:
- name: Get Labels
id: getLabels
run: |
labels="$(gh api repos/$OWNER/$REPO_NAME/pulls/$PULL_REQUEST_NUMBER --jq '.labels.[].name')"
echo "allLabels=$(echo $labels)" >> $GITHUB_OUTPUT
shell: bash
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
OWNER: ${{ github.repository_owner }}
REPO_NAME: ${{ github.event.repository.name }}
PULL_REQUEST_NUMBER: ${{ github.event.pull_request.number }}

- name: Checkout
if: "${{ contains(steps.getLabels.outputs.allLabels, 'auto-approve') }}"
uses: actions/[email protected]

- name: Was PR Opened at least Two Weeks Ago
id: twoWeeksAgo
if: "${{ contains(steps.getLabels.outputs.allLabels, 'auto-approve') }}"
run: |
created_at="$(gh api repos/$OWNER/$REPO_NAME/pulls/$PULL_REQUEST_NUMBER --jq '.created_at')"
created_at="$(date --date="${created_at}" +%Y-%m-%d)"
echo "CREATED AT: $(echo $created_at)"
date="$(date '+%Y-%m-%d')"
two_weeks_ago="$(date --date="${date} -14 day" +%Y-%m-%d)"
echo "Two Weeks Ago: $(echo $two_weeks_ago)"
if [[ "$two_weeks_ago" > "$created_at" ]];
then
echo "was_two_weeks_ago="TRUE"" >> $GITHUB_OUTPUT
else
echo "was_two_weeks_ago="FALSE"" >> $GITHUB_OUTPUT
fi
shell: bash
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
OWNER: ${{ github.repository_owner }}
REPO_NAME: ${{ github.event.repository.name }}
PULL_REQUEST_NUMBER: ${{ github.event.pull_request.number }}

- name: Auto Approve
if: "${{ contains(steps.getLabels.outputs.allLabels, 'auto-approve') && steps.twoWeeksAgo.outputs.was_two_weeks_ago == 'TRUE'}}"
uses: hmarr/auto-approve-action@v4
with:
github-token: ${{secrets.HS_APPROVER_BOT_TOKEN}}