202312 action checking pr age #7
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
name: Check PR Age | ||
on: | ||
pull_request: | ||
types: | ||
- synchronize | ||
- opened | ||
- reopened | ||
- labeled | ||
- unlabeled | ||
jobs: | ||
check-pr: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v2 | ||
- name: Check PR Age and Label fast merge | ||
run: | | ||
Check failure on line 20 in .github/workflows/pr-timing-checker.yml
|
||
PR_DATE=$(date -d "$(echo ${{ github.event.pull_request.created_at }})" +%s) | ||
CURRENT_DATE=$(date +%s) | ||
AGE_IN_SECONDS=$((CURRENT_DATE - PR_DATE)) | ||
AGE_IN_DAYS=$((AGE_IN_SECONDS / 86400)) | ||
if [ $AGE_IN_DAYS -lt 7 ]; then | ||
if [[ $(echo "${{ github.event.pull_request.labels.*.name }}" | grep -c 'pr: fast merge') -eq 0 ]]; then | ||
echo "PR is less than 7 days old (${{$AGE_IN_DAYS}}) and does not have the 'pr: fast merge' label." | ||
echo "${{ github.event.pull_request.labels.*.name }}" | ||
exit 1 | ||
fi | ||
fi | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |