validate.yml 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. name: "Validate"
  2. on:
  3. pull_request:
  4. # The branches below must be a subset of the branches above
  5. branches: [ master ] # runs on every push
  6. jobs:
  7. validate:
  8. name: Build and Validate
  9. runs-on: ubuntu-latest
  10. timeout-minutes: 10
  11. strategy:
  12. fail-fast: false
  13. matrix:
  14. node-version: [14.x]
  15. steps:
  16. - uses: actions/checkout@v1 # checkout latest commit
  17. - name: Use Node.js ${{ matrix.node-version }} # set up Node.js
  18. uses: actions/setup-node@v1
  19. with:
  20. node-version: ${{ matrix.node-version }}
  21. - name: Clean install of dependencies # runs the npm ci command to install all dependencies
  22. run: npm ci
  23. env:
  24. CI: "true"
  25. - name: Validate joke files # validates the joke files
  26. run: npm run validate-jokes
  27. env:
  28. CI: "true"
  29. - name: Validate joke IDs # makes sure all jokes have the correct ID
  30. run: npm run validate-ids
  31. env:
  32. CI: "true"
  33. - name: Send Discord success notification # sends a Discord notification
  34. env:
  35. DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
  36. uses: Ilshidur/action-discord@master
  37. with:
  38. args: '✅ **JokeAPI CI** (on `{{GITHUB_HEAD_REF}}`) was successful (see https://github.com/{{GITHUB_REPOSITORY}}/actions/runs/{{GITHUB_RUN_ID}})'
  39. if: ${{ github.actor != 'dependabot' }} # don't trigger on dependabot PRs since they don't have access to secrets
  40. - name: Send Discord failure notification # sends a Discord notification
  41. env:
  42. DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
  43. uses: Ilshidur/action-discord@master
  44. with:
  45. args: '🚫 **JokeAPI CI** (on `{{GITHUB_HEAD_REF}}`) has failed (see https://github.com/{{GITHUB_REPOSITORY}}/actions/runs/{{GITHUB_RUN_ID}})'
  46. if: ${{ failure() && github.actor != 'dependabot' }} # don't trigger on dependabot PRs since they don't have access to secrets