update-preview-deps-ci.yml 2.1 KB

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