Added floating circles animation by JoydeepBanerjee71 #91
Workflow file for this run
This file contains hidden or 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: PR Pre-review | |
| on: | |
| pull_request_target: | |
| branches: [ master ] | |
| types: [opened, synchronize, reopened] | |
| permissions: | |
| contents: read | |
| pull-requests: write | |
| issues: write | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| SKIP_REST: false | |
| jobs: | |
| pre-review: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| repository: ${{ github.event.pull_request.head.repo.full_name }} | |
| ref: ${{ github.event.pull_request.head.sha }} | |
| fetch-depth: 50 | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: 20 | |
| cache: 'npm' | |
| - name: Fetch master branch | |
| run: git fetch origin master | |
| - name: Collect information | |
| run: | | |
| # Environment variables used with "preReview.js" | |
| echo "Setting environment variable for \"preReview.js\"" | |
| setEnv() { | |
| echo "$1=${!1}" >> $GITHUB_ENV | |
| } | |
| # PR author (the contributor) | |
| CONTRIBUTOR=${{ github.event.pull_request.user.login }}; | |
| setEnv "CONTRIBUTOR"; | |
| echo "Contributor github handle: $CONTRIBUTOR" | |
| MERGE_BASE=$(git merge-base origin/master HEAD 2>/dev/null || echo HEAD~1); | |
| GITHUB_HANDLE=${GITHUB_TRIGGERING_ACTOR:-local-actor}; setEnv "GITHUB_HANDLE"; | |
| CHANGED_FILES=$(gh pr view ${{ github.event.pull_request.number }} --json files -q '.files[].path') | |
| echo "CHANGED_FILES<<EOF" >> $GITHUB_ENV | |
| printf '%s\n' "$CHANGED_FILES" >> $GITHUB_ENV | |
| echo "EOF" >> $GITHUB_ENV | |
| GITHUB_PERMISSION_ROLE=$(gh api "repos/$GITHUB_REPOSITORY/collaborators/$CONTRIBUTOR/permission" -q '.role_name' 2>/dev/null || echo 'unknown'); | |
| setEnv "GITHUB_PERMISSION_ROLE"; | |
| - name: Run "preReview" script | |
| id: pre-review | |
| run: | | |
| PR_NUMBER=${{ github.event.pull_request.number }}; | |
| REVIEW_MESSAGE=$(node ./generators/preReview.js "$CONTRIBUTOR" "$CHANGED_FILES" "$GITHUB_PERMISSION_ROLE"); | |
| echo "REVIEW_MESSAGE<<EOF" >> $GITHUB_ENV; | |
| echo "$REVIEW_MESSAGE" >> $GITHUB_ENV; | |
| echo "EOF" >> $GITHUB_ENV; | |
| # Show in logs | |
| echo "===== REVIEW_MESSAGE =====" | |
| echo "$REVIEW_MESSAGE" | |
| echo "==========================" | |
| # Submit review | |
| echo "Submit review comment" | |
| gh pr comment "$PR_NUMBER" --body "$REVIEW_MESSAGE" -R "${{ github.event.pull_request.base.repo.full_name }}" | |
| # Add "Requested Changes" label + assign contributor | |
| echo "Handle \"Changes Requested\" label and contributor assignment" | |
| if echo "$REVIEW_MESSAGE" | grep -q '\- \[ \]'; then | |
| # Only assign if contributor is a collaborator | |
| if [[ "$GITHUB_PERMISSION_ROLE" != "unknown" ]]; then | |
| gh pr edit "$PR_NUMBER" --add-assignee "$CONTRIBUTOR" -R "${{ github.event.pull_request.base.repo.full_name }}" | |
| fi | |
| # Always add "Changes Requested" label | |
| gh pr edit "$PR_NUMBER" --add-label "Changes Requested" -R "${{ github.event.pull_request.base.repo.full_name }}" | |
| else | |
| # Remove the label if no changes requested | |
| gh pr edit "$PR_NUMBER" --remove-label "Changes Requested" -R "${{ github.event.pull_request.base.repo.full_name }}" | |
| fi | |
| # Add "invalid" label when changes are out of Art/ folder (and not maintainer) | |
| echo "Handle label \"invalid\"" | |
| if echo "$REVIEW_MESSAGE" | grep -q -Eqi 'empty file'; then | |
| gh pr edit "$PR_NUMBER" --add-label "invalid" -R "${{ github.event.pull_request.base.repo.full_name }}"; | |
| else | |
| gh pr edit "$PR_NUMBER" --remove-label "invalid" -R "${{ github.event.pull_request.base.repo.full_name }}"; | |
| fi | |
| # Add "Conflict present" when an icon is present in changes | |
| echo "Handle label \"Conflict present\"" | |
| if echo "$REVIEW_MESSAGE" | grep -q -Eqi '/icon'; then | |
| gh pr edit "$PR_NUMBER" --add-label "Conflict present" -R "${{ github.event.pull_request.base.repo.full_name }}"; | |
| else | |
| gh pr edit "$PR_NUMBER" --remove-label "Conflict present" -R "${{ github.event.pull_request.base.repo.full_name }}"; | |
| fi | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| maintainer-review: | |
| needs: pre-review | |
| if: github.event_name == 'pull_request_review' | |
| runs-on: ubuntu-latest | |
| steps: | |
| # While reviewing on github, this automatically assign labels on review actions. | |
| # When submiting a review (reminder, this cannot run for maintainers reviewing their own PRs.) | |
| # - Label "Changes Requested" on "request changes" review action | |
| # - Label "hacktoberfest-accepted" on "aprove" review action only if current date is in October | |
| - name: Show previous review message | |
| run: | | |
| echo "Message from pre-review job:" | |
| echo "${{ needs.pre-review.outputs.review_message }}" | |
| - name: Add labels depending on maintainer review | |
| run: | | |
| PR_NUMBER=${{ github.event.pull_request.number }} | |
| REVIEW_STATE=${{ github.event.review.state }} | |
| CURRENT_MONTH=$(date +%m) | |
| if [[ "$REVIEW_STATE" == "changes_requested" ]]; then | |
| gh pr edit "$PR_NUMBER" --add-label "Changes Requested" -R "${{ github.event.pull_request.base.repo.full_name }}" | |
| echo "Maintainer requested changes — label added." | |
| fi | |
| # Add Hacktoberfest label only if current month is October (10) | |
| if [[ "$CURRENT_MONTH" == "10" && "$REVIEW_STATE" == "approved" ]]; then | |
| gh pr edit "$PR_NUMBER" --add-label "hacktoberfest-accepted" -R "${{ github.event.pull_request.base.repo.full_name }}" | |
| fi | |