update-preview-deps-ci.yml 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. name: "Update Preview Dependencies (feat/ci)"
  2. on:
  3. workflow_dispatch:
  4. jobs:
  5. update:
  6. runs-on: ubuntu-latest
  7. steps:
  8. - name: Cancel Previous Runs
  9. uses: styfle/cancel-workflow-action@0.9.1
  10. with:
  11. access_token: ${{ github.token }}
  12. - name: Checkout
  13. uses: actions/checkout@v2.3.5
  14. with:
  15. ref: 'ci'
  16. - name: Setup Node.js 20
  17. uses: actions/setup-node@v3
  18. with:
  19. node-version: 20
  20. - name: Remove yarn.lock
  21. run: rm yarn.lock
  22. - name: Install Dependencies
  23. run: yarn
  24. - name: Close Previous PRs
  25. shell: "bash"
  26. run: |
  27. PR_LIST=$(gh pr list --base ci --json number,headRefName)
  28. # Filter out PRs where headRefName starts with 'chore/update-preview'
  29. FILTERED_PR_LIST=$(echo "$PR_LIST" | jq '[.[] | select(.headRefName | test("^chore/update-preview"))]')
  30. echo "$FILTERED_PR_LIST"
  31. # Check if any pull requests were found after filtering
  32. if [ -z "$FILTERED_PR_LIST" ] || [ "$FILTERED_PR_LIST" = "[]" ]; then
  33. echo "No pull requests found on branch ci after filtering"
  34. exit 0
  35. fi
  36. # Close each filtered pull request
  37. echo "$FILTERED_PR_LIST" | jq -r '.[].number' | while read -r PR_NUMBER; do
  38. echo "Closing pull request #$PR_NUMBER"
  39. gh pr close "$PR_NUMBER" -d
  40. done
  41. env:
  42. GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  43. OWNER: ${{ github.repository_owner }}
  44. REPO: ${{ github.event.repository.name }}
  45. - name: Open PR with changes
  46. uses: peter-evans/create-pull-request@v5
  47. with:
  48. title: "chore(ci): updated preview dependencies [automated]"
  49. commit-message: "chore(ci): updated preview dependencies [automated]"
  50. body: "This PR updates preview dependencies to the latest versions."
  51. branch: "chore/update-preview"
  52. branch-suffix: "timestamp"
  53. token: ${{ secrets.PAT_TOKEN }}
  54. base: "ci"
  55. add-paths: yarn.lock
  56. committer: "GitHub <noreply@github.com>"
  57. author: "GitHub <github-actions[bot]@users.noreply.github.com>"