update-preview-deps.yml 2.2 KB

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