|
| 1 | +name: Lint |
| 2 | +on: |
| 3 | + pull_request: |
| 4 | + branches: |
| 5 | + - main |
| 6 | + push: |
| 7 | + branches: |
| 8 | + - main |
| 9 | + |
| 10 | +jobs: |
| 11 | + cache: |
| 12 | + name: CI cache |
| 13 | + runs-on: ubuntu-latest |
| 14 | + outputs: |
| 15 | + yarn-cache-key: ${{ steps.yarn-cache-key.outputs.key }} |
| 16 | + steps: |
| 17 | + - uses: actions/checkout@v2 |
| 18 | + - uses: actions/setup-node@v2 |
| 19 | + with: |
| 20 | + node-version: '16.x' |
| 21 | + - name: Remove git auth |
| 22 | + run: git config --unset http.https://github.com/.extraheader |
| 23 | + - name: Generate yarn cache-key |
| 24 | + id: yarn-cache-key |
| 25 | + run: echo "::set-output name=key::${{ runner.os }}-yarn-ci-cache-v3-${{ hashFiles('./yarn.lock') }}-${{ hashFiles('**/yarn.lock') }}" |
| 26 | + - name: Configure Yarn cache |
| 27 | + uses: actions/cache@v2 |
| 28 | + with: |
| 29 | + key: ${{ steps.yarn-cache-key.outputs.key }} |
| 30 | + path: | |
| 31 | + ~/.cache/Cypress |
| 32 | + .yarn |
| 33 | + node_modules |
| 34 | + - name: Install dependencies |
| 35 | + if: ${{ github.actor != 'dependabot[bot]' || github.ref == 'refs/heads/main' }} |
| 36 | + run: yarn --immutable |
| 37 | + - name: Install dependencies & update yarn.lock (dependabot) |
| 38 | + if: ${{ github.actor == 'dependabot[bot]' && github.ref != 'refs/heads/main' }} |
| 39 | + run: "yarn install && git stage yarn.lock && git commit -m 'chore: update yarn.lock' && git push" |
| 40 | + env: |
| 41 | + YARN_ENABLE_IMMUTABLE_INSTALLS: false |
| 42 | + |
| 43 | + lint: |
| 44 | + name: lint |
| 45 | + runs-on: ubuntu-latest |
| 46 | + needs: cache |
| 47 | + steps: |
| 48 | + - uses: actions/checkout@v2 |
| 49 | + - uses: actions/setup-node@v2 |
| 50 | + with: |
| 51 | + node-version: '16.x' |
| 52 | + - name: remove git auth |
| 53 | + run: git config --unset http.https://github.com/.extraheader |
| 54 | + - name: Configure Yarn cache |
| 55 | + uses: actions/cache@v2 |
| 56 | + with: |
| 57 | + key: ${{ needs.cache.outputs.yarn-cache-key }} |
| 58 | + path: | |
| 59 | + ~/.cache/Cypress |
| 60 | + .yarn |
| 61 | + node_modules |
| 62 | + - name: Install dependencies |
| 63 | + run: yarn --immutable |
| 64 | + - name: Lint |
| 65 | + run: yarn lint.ci |
| 66 | + - name: Prettify |
| 67 | + run: yarn prettify && git diff-index --quiet HEAD |
| 68 | + |
| 69 | + build-and-release: |
| 70 | + name: build and release |
| 71 | + runs-on: ubuntu-latest |
| 72 | + needs: [cache, lint] |
| 73 | + if: ${{ github.actor != 'dependabot[bot]' }} |
| 74 | + steps: |
| 75 | + - uses: actions/checkout@v2 |
| 76 | + with: |
| 77 | + # pulls all commits (needed for lerna / semantic release to correctly version) |
| 78 | + fetch-depth: "0" |
| 79 | + - name: Setup git user |
| 80 | + run: | |
| 81 | + git config --global user.name "$(git --no-pager log --format=format:'%an' -n 1)" |
| 82 | + git config --global user.email "$(git --no-pager log --format=format:'%ae' -n 1)" |
| 83 | + - name: Pull git tags (needed for lerna / semantic release to correctly version) |
| 84 | + run: git fetch --prune --unshallow --tags |
| 85 | + - uses: actions/setup-node@v2 |
| 86 | + with: |
| 87 | + node-version: '16.x' |
| 88 | + - name: remove git auth |
| 89 | + run: git config --unset http.https://github.com/.extraheader |
| 90 | + - name: Configure Yarn cache |
| 91 | + uses: actions/cache@v2 |
| 92 | + with: |
| 93 | + key: ${{ needs.cache.outputs.yarn-cache-key }} |
| 94 | + path: | |
| 95 | + ~/.cache/Cypress |
| 96 | + .yarn |
| 97 | + node_modules |
| 98 | + - name: Install dependencies |
| 99 | + run: yarn --immutable |
| 100 | + - name: Authenticate with Registry |
| 101 | + run: | |
| 102 | + yarn logout |
| 103 | + echo "registry=http://registry.npmjs.org/" >> .npmrc |
| 104 | + echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> .npmrc |
| 105 | + npm whoami |
| 106 | + env: |
| 107 | + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} |
| 108 | + - name: release package |
| 109 | + if: ${{ success() && github.actor != 'dependabot[bot]' && github.ref == 'refs/heads/main' && github.event_name == 'push' }} |
| 110 | + run: yarn release:ci |
| 111 | + env: |
| 112 | + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} |
| 113 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 114 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments