ci.yml 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. name: CI
  2. on:
  3. pull_request_target:
  4. branches:
  5. - main
  6. permissions:
  7. pull-requests: write
  8. jobs:
  9. job1:
  10. name: Check Not Allowed File Changes
  11. runs-on: ubuntu-latest
  12. outputs:
  13. markdown_change: ${{ steps.filter_markdown.outputs.change }}
  14. markdown_files: ${{ steps.filter_markdown.outputs.change_files }}
  15. steps:
  16. - name: Check Not Allowed File Changes
  17. uses: dorny/paths-filter@v2
  18. id: filter_not_allowed
  19. with:
  20. list-files: json
  21. filters: |
  22. change:
  23. - 'package-lock.json'
  24. - 'yarn.lock'
  25. - 'pnpm-lock.yaml'
  26. # ref: https://github.com/github/docs/blob/main/.github/workflows/triage-unallowed-contributions.yml
  27. - name: Comment About Changes We Can't Accept
  28. if: ${{ steps.filter_not_allowed.outputs.change == 'true' }}
  29. uses: actions/github-script@v6
  30. with:
  31. script: |
  32. let workflowFailMessage = "It looks like you've modified some files that we can't accept as contributions."
  33. try {
  34. const badFilesArr = [
  35. 'package-lock.json',
  36. 'yarn.lock',
  37. 'pnpm-lock.yaml',
  38. ]
  39. const badFiles = badFilesArr.join('\n- ')
  40. const reviewMessage = `👋 Hey there spelunker. It looks like you've modified some files that we can't accept as contributions. The complete list of files we can't accept are:\n- ${badFiles}\n\nYou'll need to revert all of the files you changed in that list using [GitHub Desktop](https://docs.github.com/en/free-pro-team@latest/desktop/contributing-and-collaborating-using-github-desktop/managing-commits/reverting-a-commit) or \`git checkout origin/main <file name>\`. Once you get those files reverted, we can continue with the review process. :octocat:\n\nMore discussion:\n- https://github.com/electron-vite/electron-vite-vue/issues/192`
  41. createdComment = await github.rest.issues.createComment({
  42. owner: context.repo.owner,
  43. repo: context.repo.repo,
  44. issue_number: context.payload.number,
  45. body: reviewMessage,
  46. })
  47. workflowFailMessage = `${workflowFailMessage} Please see ${createdComment.data.html_url} for details.`
  48. } catch(err) {
  49. console.log("Error creating comment.", err)
  50. }
  51. core.setFailed(workflowFailMessage)
  52. - name: Check Not Linted Markdown
  53. if: ${{ always() }}
  54. uses: dorny/paths-filter@v2
  55. id: filter_markdown
  56. with:
  57. list-files: shell
  58. filters: |
  59. change:
  60. - added|modified: '*.md'
  61. job2:
  62. name: Lint Markdown
  63. runs-on: ubuntu-latest
  64. needs: job1
  65. if: ${{ always() && needs.job1.outputs.markdown_change == 'true' }}
  66. steps:
  67. - name: Checkout Code
  68. uses: actions/checkout@v3
  69. with:
  70. ref: ${{ github.event.pull_request.head.sha }}
  71. - name: Lint markdown
  72. run: npx markdownlint-cli ${{ needs.job1.outputs.markdown_files }} --ignore node_modules