|
| 1 | +name: CI |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [develop, beta] |
| 6 | + pull_request: |
| 7 | + branches: [develop, beta] |
| 8 | + |
| 9 | +jobs: |
| 10 | + build-and-test: |
| 11 | + name: ${{ matrix.command_description }} |
| 12 | + uses: ./.github/workflows/test.yml |
| 13 | + strategy: |
| 14 | + fail-fast: false |
| 15 | + matrix: |
| 16 | + include: |
| 17 | + - command_description: Build |
| 18 | + command: npm run build |
| 19 | + needs_lfs: false |
| 20 | + needs_playwright: false |
| 21 | + - command_description: Lint |
| 22 | + command: npm run lint |
| 23 | + needs_lfs: false |
| 24 | + needs_playwright: false |
| 25 | + - command_description: Less Tests |
| 26 | + command: npm run test:less -w packages/stacks-classic |
| 27 | + needs_lfs: false |
| 28 | + needs_playwright: false |
| 29 | + - command_description: Unit Tests |
| 30 | + command: npm run test:unit -w packages/stacks-classic -- --config web-test-runner.config.ci.mjs |
| 31 | + needs_lfs: false |
| 32 | + needs_playwright: true |
| 33 | + - command_description: A11y Tests |
| 34 | + command: npm run test:a11y -w packages/stacks-classic -- --config web-test-runner.config.ci.mjs |
| 35 | + needs_lfs: false |
| 36 | + needs_playwright: true |
| 37 | + - command_description: Visual Regression Tests |
| 38 | + command: npm run test:visual:ci -w packages/stacks-classic -- --config ./visual-runner/stacks-classic-runner-config/web-test-runner.config.ci.mjs |
| 39 | + needs_lfs: true |
| 40 | + needs_playwright: false # we are using playwright docker image to run visual tests |
| 41 | + - command_description: Unit Tests (stacks-svelte) |
| 42 | + command: npm run test -w packages/stacks-svelte |
| 43 | + needs_lfs: false |
| 44 | + needs_playwright: true |
| 45 | + with: |
| 46 | + command: ${{ matrix.command }} |
| 47 | + command_description: ${{ matrix.command_description }} |
| 48 | + needs_playwright: ${{ matrix.needs_playwright }} |
| 49 | + needs_lfs: ${{ matrix.needs_lfs }} |
| 50 | + |
| 51 | + release: |
| 52 | + name: Release (latest or beta) |
| 53 | + if: github.ref == 'refs/heads/develop' || github.ref == 'refs/heads/beta' |
| 54 | + needs: [build-and-test] |
| 55 | + runs-on: ubuntu-latest |
| 56 | + outputs: |
| 57 | + published: ${{ steps.changesets.outputs.published }} |
| 58 | + steps: |
| 59 | + - uses: actions/checkout@v5 |
| 60 | + - name: Setup Node.js environment |
| 61 | + uses: actions/setup-node@v4 |
| 62 | + with: |
| 63 | + node-version: lts/* |
| 64 | + cache: "npm" |
| 65 | + - name: Install dependencies |
| 66 | + run: | |
| 67 | + npm ci |
| 68 | + npm run build |
| 69 | + - name: 🚀 Create/Update Release Pull Request or Publish to npm |
| 70 | + id: changesets |
| 71 | + uses: changesets/action@v1 |
| 72 | + with: |
| 73 | + version: npm run version |
| 74 | + publish: npm run release |
| 75 | + title: "chore(new-release)" |
| 76 | + commit: "chore(new-release)" |
| 77 | + branch: ${{ github.ref == 'refs/heads/beta' && 'beta' || null }} |
| 78 | + createGithubReleases: ${{ github.ref == 'refs/heads/develop' }} |
| 79 | + env: |
| 80 | + GITHUB_TOKEN: ${{ secrets.STACKS_TOOLING_GH_RW_PAT }} |
| 81 | + NPM_TOKEN: ${{ secrets.NPM_API_KEY }} |
| 82 | + - name: Docs on Release Pull Request |
| 83 | + # run only if there is a release pull request open |
| 84 | + if: steps.changesets.outputs.pullRequestNumber |
| 85 | + uses: thollander/actions-comment-pull-request@v3 |
| 86 | + with: |
| 87 | + comment-tag: "pr-release-docs" |
| 88 | + pr-number: ${{ steps.changesets.outputs.pullRequestNumber }} |
| 89 | + message: | |
| 90 | + To trigger the build for this PR, **close and re-open it**. |
| 91 | + This is necessary because the PR is updated by github-actions[bot]. |
| 92 | + This is a technical user which does not trigger actions workflows on push events. |
| 93 | + See this GH issue for more details: https://github.com/changesets/action/issues/187 |
| 94 | +
|
| 95 | + update-docs: |
| 96 | + name: Update main site stackoverflow.design |
| 97 | + if: ${{ needs.release.outputs.published == 'true' && github.ref == 'refs/heads/develop' }} |
| 98 | + needs: [build-and-test, release] |
| 99 | + runs-on: ubuntu-latest |
| 100 | + steps: |
| 101 | + - name: 🔄 Update stackoverflow.design docs |
| 102 | + run: | |
| 103 | + git config --global user.name 'github-actions[bot]' |
| 104 | + git config --global user.email 'github-actions[bot]@users.noreply.github.com' |
| 105 | + git fetch origin |
| 106 | + git checkout production |
| 107 | + git merge --no-ff --allow-unrelated-histories origin/develop -m "chore: merge develop into production" |
| 108 | + git push origin production |
| 109 | + env: |
| 110 | + GITHUB_TOKEN: ${{ secrets.STACKS_TOOLING_GH_RW_PAT }} |
| 111 | + |
| 112 | +# cancel the jobs if another workflow is kicked off for the same branch |
| 113 | +concurrency: |
| 114 | + group: ${{ github.workflow }}-${{ github.ref }} |
| 115 | + cancel-in-progress: true |
0 commit comments