mikeals-workflow.yml 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. on: [push, pull_request]
  2. name: Build, Test and maybe Publish
  3. jobs:
  4. test:
  5. name: Build & Test
  6. runs-on: ubuntu-latest
  7. strategy:
  8. matrix:
  9. node-version: [12.x, 14.x]
  10. steps:
  11. - uses: actions/checkout@v2
  12. - name: Use Node.js ${{ matrix.node-version }}
  13. uses: actions/setup-node@v1
  14. with:
  15. node-version: ${{ matrix.node-version }}
  16. - name: Cache node_modules
  17. id: cache-modules
  18. uses: actions/cache@v1
  19. with:
  20. path: node_modules
  21. key: ${{ matrix.node-version }}-${{ runner.OS }}-build-${{ hashFiles('package.json') }}
  22. - name: Build
  23. if: steps.cache-modules.outputs.cache-hit != 'true'
  24. run: npm install
  25. - name: Test
  26. run: npm_config_yes=true npx best-test@latest
  27. publish:
  28. name: Publish
  29. needs: test
  30. runs-on: ubuntu-latest
  31. if: github.event_name == 'push' && ( github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main' )
  32. steps:
  33. - uses: actions/checkout@v2
  34. - name: Cache node_modules
  35. id: cache-modules
  36. uses: actions/cache@v1
  37. with:
  38. path: node_modules
  39. key: 12.x-${{ runner.OS }}-build-${{ hashFiles('package.json') }}
  40. - name: Build
  41. if: steps.cache-modules.outputs.cache-hit != 'true'
  42. run: npm install
  43. - name: Test
  44. run: npm_config_yes=true npx best-test@latest
  45. - name: Publish
  46. uses: mikeal/merge-release@master
  47. env:
  48. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  49. NPM_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}