Skip to content

Commit

Permalink
Commit File
Browse files Browse the repository at this point in the history
  • Loading branch information
clpendleton committed Nov 5, 2024
1 parent 52b635f commit cfce8a2
Showing 1 changed file with 55 additions and 0 deletions.
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}}

0 comments on commit cfce8a2

Please sign in to comment.