forked from terraform-community-modules/tf_aws_vpc
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
52b635f
commit cfce8a2
Showing
1 changed file
with
55 additions
and
0 deletions.
There are no files selected for viewing
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
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}} |