|
| 1 | +name: Node.js CI |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - master |
| 7 | + pull_request: |
| 8 | + |
| 9 | +jobs: |
| 10 | + test-build-release: |
| 11 | + env: |
| 12 | + IS_PUSH_TO_MASTER: ${{ github.event.push && github.ref == 'refs/heads/master' }} |
| 13 | + |
| 14 | + runs-on: ubuntu-latest |
| 15 | + |
| 16 | + steps: |
| 17 | + - uses: actions/checkout@v2 |
| 18 | + - name: Use Node.js 12.x |
| 19 | + uses: actions/setup-node@v1 |
| 20 | + with: |
| 21 | + node-version: 12.x |
| 22 | + - name: Install npm packages using cache |
| 23 | + uses: bahmutov/npm-install@v1 |
| 24 | + - name: Lint code |
| 25 | + run: yarn lint |
| 26 | + - name: Run tests with coverage |
| 27 | + run: yarn cover |
| 28 | + |
| 29 | + # at this point, the build is successful |
| 30 | + - name: Codecov |
| 31 | + |
| 32 | + continue-on-error: true |
| 33 | + - name: Semantic Release |
| 34 | + env: |
| 35 | + GH_TOKEN: ${{ secrets.GH_TOKEN }} |
| 36 | + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} |
| 37 | + run: yarn semantic-release |
| 38 | + |
| 39 | + # Steps below deal with uploading Storybook to S3, |
| 40 | + # which is only performed with a push to the main branch. |
| 41 | + # Note that AWS CLI v2 is already installed by default on GitHub's Ubuntu 20.04. |
| 42 | + # per https://github.com/actions/virtual-environments/blob/main/images/linux/Ubuntu2004-README.md#cli-tools. |
| 43 | + - name: Add AWS credentials |
| 44 | + if: ${{ env.IS_PUSH_TO_MASTER }} |
| 45 | + run: mkdir ~/.aws && printf '%s\n' '[default]' "aws_access_key_id=$AWS_ACCESS_KEY_ID" "aws_secret_access_key=$AWS_SECRET_ACCESS_KEY" "region=$AWS_REGION" > ~/.aws/config |
| 46 | + env: |
| 47 | + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} |
| 48 | + AWS_REGION: ${{ secrets.AWS_REGION }} |
| 49 | + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} |
| 50 | + # Deploy storybook demo to S3 if handling a push (non-PR build) on the main branch |
| 51 | + # https://s3.amazonaws.com/transitive.js/index.html |
| 52 | + - name: Deploy storybook to S3 |
| 53 | + if: ${{ env.IS_PUSH_TO_MASTER }} |
| 54 | + run: yarn deploy-storybook |
0 commit comments