name: CI on: [push] jobs: version: runs-on: ubuntu-18.04 container: image: codacy/git-version steps: - uses: actions/checkout@v1 - name: Configure Git run: | git checkout -f ${GITHUB_REF#refs/heads/} git config user.email "$GITHUB_ACTOR@users.noreply.github.com" git config user.name "$GITHUB_ACTOR" - name: Get next version id: git-version run: | export NEXT_VERSION="$(/bin/git-version --folder=$PWD)" echo "Next version is ${NEXT_VERSION}" echo "${NEXT_VERSION}" > version.txt - name: Save version artifact uses: actions/upload-artifact@v1 with: name: version path: version.txt build: runs-on: ubuntu-18.04 needs: version env: CI: true strategy: matrix: node-version: [10.x, 11.x, 12.x, 13.x] steps: - uses: actions/checkout@v1 - name: Setup Node.js ${{ matrix.node-version }} uses: actions/setup-node@v1 with: node-version: ${{ matrix.node-version }} - run: node -v - run: yarn -v - name: Get yarn cache id: yarn-cache run: echo "::set-output name=dir::$(yarn cache dir)" - uses: actions/cache@v1 with: path: ${{ steps.yarn-cache.outputs.dir }} key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} restore-keys: | ${{ runner.os }}-yarn- - name: Install dependencies run: yarn install - name: Build run: yarn run build - name: Lint run: yarn run lint - name: Test run: yarn run coverage - name: Push coverage to Codacy if: matrix.node-version == '13.x' env: CODACY_PROJECT_TOKEN: ${{ secrets.CODACY_PROJECT_TOKEN }} run: yarn run codacy - name: Save coverage report if: matrix.node-version == '13.x' uses: actions/upload-artifact@v1 with: name: coverage path: coverage - name: Save website artifact if: matrix.node-version == '13.x' uses: actions/upload-artifact@v1 with: name: website path: docs deploy: if: github.ref == 'refs/heads/master' needs: build runs-on: ubuntu-18.04 steps: - name: Download website artifact uses: actions/download-artifact@v1 with: name: website - name: Deploy website env: AWS_DEFAULT_REGION: ${{ secrets.AWS_DEFAULT_REGION }} AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} run: | cd docs aws s3 sync . s3://diff2html.xyz --region eu-west-1 publish: if: github.ref == 'refs/heads/github-workflows' needs: build runs-on: ubuntu-18.04 env: CI: true steps: - uses: actions/checkout@v1 - name: Download version artifact uses: actions/download-artifact@v1 with: name: version - uses: actions/setup-node@v1 with: node-version: 13 - name: Configure Yarn version run: | yarn config set version-tag-prefix "" yarn config set version-git-message "Release version %s" - name: Configure Git run: | git switch -c $GITHUB_REF git config user.email "$GITHUB_ACTOR@users.noreply.github.com" git config user.name "$GITHUB_ACTOR" - name: Install dependencies run: yarn install - name: Prepare version env: GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} run: | yarn version --non-interactive --new-version $(cat version/version.txt) git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$GITHUB_REPOSITORY" git push --tags "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$GITHUB_REPOSITORY" - uses: actions/setup-node@v1 with: node-version: 13 registry-url: https://registry.npmjs.org/ - name: Publish to NPM env: NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}} run: | echo "Going to publish version $(cat version/version.txt) to NPM" yarn publish --tag latest --non-interactive --new-version $(cat version/version.txt) # - uses: actions/setup-node@v1 # with: # node-version: 13 # registry-url: https://npm.pkg.github.com # scope: "@rtfpessoa" # - name: Publish to GitHub # env: # NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}} # run: | # echo "Going to publish version $(cat version/version.txt) to GitHub" # yarn publish --tag latest --non-interactive --new-version $(cat version/version.txt)