|
| 1 | +# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node |
| 2 | +# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions |
| 3 | + |
| 4 | +name: Deploy Bundle |
| 5 | + |
| 6 | +on: |
| 7 | + push: |
| 8 | + branches: |
| 9 | + - master |
| 10 | + |
| 11 | +jobs: |
| 12 | + check-version: |
| 13 | + runs-on: ubuntu-latest |
| 14 | + steps: |
| 15 | + - uses: actions/checkout@v2 |
| 16 | + |
| 17 | + - name: Version Check |
| 18 | + id: check |
| 19 | + uses: EndBug/version-check@v1.3.0 |
| 20 | + |
| 21 | + - name: Has version changed? |
| 22 | + if: steps.check.outputs.changed != 'true' |
| 23 | + run: 'echo "No version change :/" && exit 1' |
| 24 | + |
| 25 | + build: |
| 26 | + needs: check-version |
| 27 | + runs-on: ubuntu-latest |
| 28 | + |
| 29 | + strategy: |
| 30 | + matrix: |
| 31 | + node-version: [10.x, 12.x] |
| 32 | + |
| 33 | + steps: |
| 34 | + - uses: actions/checkout@v2 |
| 35 | + |
| 36 | + - name: Use Node.js ${{ matrix.node-version }} |
| 37 | + uses: actions/setup-node@v1 |
| 38 | + with: |
| 39 | + node-version: ${{ matrix.node-version }} |
| 40 | + |
| 41 | + - run: npm ci |
| 42 | + |
| 43 | + - run: npm run build --if-present |
| 44 | + |
| 45 | + - run: npm test |
| 46 | + |
| 47 | + - name: Upload dist files |
| 48 | + uses: actions/upload-artifact@v2 |
| 49 | + with: |
| 50 | + name: dist-files |
| 51 | + path: dist |
| 52 | + |
| 53 | + commit: |
| 54 | + needs: [build, check-version] |
| 55 | + runs-on: ubuntu-latest |
| 56 | + steps: |
| 57 | + - uses: actions/checkout@v2 |
| 58 | + - uses: actions/setup-node@v1 |
| 59 | + with: |
| 60 | + node-version: ${{ matrix.node-version }} |
| 61 | + registry-url: https://registry.npmjs.org/ |
| 62 | + |
| 63 | + - name: Download dist files |
| 64 | + uses: actions/download-artifact@v2 |
| 65 | + with: |
| 66 | + name: dist-files |
| 67 | + path: dist |
| 68 | + |
| 69 | + - name: Commit changes |
| 70 | + uses: EndBug/add-and-commit@v4 |
| 71 | + with: |
| 72 | + author_name: mParticle Automation |
| 73 | + author_email: developers@mparticle.com |
| 74 | + message: 'Generate latest bundle' |
| 75 | + force: true |
| 76 | + add: 'dist/' |
| 77 | + env: |
| 78 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 79 | + |
| 80 | + publish-npm: |
| 81 | + needs: [build, check-version, commit] |
| 82 | + runs-on: ubuntu-latest |
| 83 | + steps: |
| 84 | + - uses: actions/checkout@v2 |
| 85 | + - uses: actions/setup-node@v1 |
| 86 | + with: |
| 87 | + node-version: ${{ matrix.node-version }} |
| 88 | + registry-url: https://registry.npmjs.org/ |
| 89 | + - run: npm ci |
| 90 | + - run: npm publish |
| 91 | + env: |
| 92 | + NODE_AUTH_TOKEN: ${{secrets.NPM_AUTH_TOKEN}} |
0 commit comments