Add storybook #1340
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Pre-Release | |
| on: | |
| # On push on a PR we want to trigger a normal build without publishing anything | |
| pull_request: | |
| branches: [ main ] | |
| types: | |
| - opened | |
| - reopened | |
| - synchronize | |
| - ready_for_review | |
| # Manual trigger means we want to produce published prerelease artifacts for retesting purposes | |
| workflow_dispatch: | |
| env: | |
| NODE_VERSION: 24 | |
| # https://github.com/actions/runner-images/issues/70 | |
| NODE_OPTIONS: "--max_old_space_size=4096" | |
| PNPM_VERSION: ^10.9 | |
| NPM_CONFIG_@coremedia:registry: 'https://repository.coremedia.com/nexus/repository/coremedia-npm' | |
| NPM_CONFIG_@coremedia-internal:registry: 'https://repository.coremedia.com/nexus/repository/coremedia-npm' | |
| jobs: | |
| build: | |
| name: Build | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 30 | |
| # do not run when if it is a manual trigger on the main branch as we have other CI for this. This one is only for feature branches | |
| if: (github.event_name != 'workflow_dispatch' || github.ref != 'refs/heads/main') && !github.event.pull_request.draft | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v5 | |
| - name: Allocate PR Number for manual trigger | |
| id: read-prnumber | |
| if: github.event_name == 'workflow_dispatch' | |
| run: | | |
| prnumber=$(curl -s -H "Accept: application/vnd.github.v3+json" -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" https://api.github.com/repos/${{github.repository}}/pulls?head=${{github.repository_owner}}:${{github.ref}} | jq -r '.[] | .number' ) | |
| echo "Allocated Pull Request number ${prnumber}" | |
| echo "::set-output name=prnumber::${prnumber}" | |
| - name: Use Node.js ${{ env.NODE_VERSION }} | |
| uses: actions/setup-node@v5 | |
| with: | |
| node-version: ${{ env.NODE_VERSION }} | |
| - name: Configure NPM | |
| run: | | |
| NPM_AUTH_TOKEN=$(curl -s -H "Accept: application/json" -H "Content-Type:application/json" -X PUT --data '{"name": "${{ secrets.PLUGINS_NEXUS_USER }}", "password": "${{ secrets.PLUGINS_NEXUS_PASSWORD }}"}' https://repository.coremedia.com/nexus/repository/coremedia-npm/-/user/org.couchdb.user:${{ secrets.PLUGINS_NEXUS_USER }} | jq -r .token) | |
| echo "::add-mask::$NPM_AUTH_TOKEN" | |
| echo "NPM_AUTH_TOKEN=$NPM_AUTH_TOKEN" >> $GITHUB_ENV | |
| echo "NPM_CONFIG_//repository.coremedia.com/nexus/repository/coremedia-npm/:_authToken=$NPM_AUTH_TOKEN" >> $GITHUB_ENV | |
| npm install -g pnpm@${{ env.PNPM_VERSION }} | |
| - name: Setup Git | |
| run: | | |
| git config --global user.name 'coremedia-ci' | |
| git config --global user.email 'coremedia-ci@coremedia.com' | |
| - name: Install | |
| run: pnpm install | |
| - name: Set prerelease version (if triggered manually) | |
| if: github.event_name == 'workflow_dispatch' | |
| run: | | |
| if [ -n "$(git status --porcelain)" ]; then | |
| git status | |
| echo "error:: There are unexpected changes in git!"; | |
| exit 1 | |
| fi | |
| actual_version=$(cat .release-version) | |
| prnumber=${{ steps.read-prnumber.outputs.prnumber }} | |
| next_version=$(pnpm --silent "script:version" --pull-request ${prnumber} --run-number ${{ github.run_number }}) | |
| # Remember the resolved version for the later "Restore workspace dependency versions" step. | |
| echo "NEXT_VERSION=${next_version}" >> $GITHUB_ENV | |
| pnpm run setversion ${next_version} --filter=coremedia/* --dependencyVersion=workspace:${next_version} | |
| git commit -am "Set next pre-release version to: ${next_version}" | |
| pnpm install --no-frozen-lockfile | |
| git commit -am "ci: Update pnpm-lock.yaml for version ${next_version}" | |
| echo "**Pre-Release Version:** ${next_version}" >> $GITHUB_STEP_SUMMARY | |
| - name: Create env file | |
| run: | | |
| touch .env | |
| echo CKEDITOR_LICENSE_KEY=${{ secrets.CKEDITOR_LICENSE}}>> .env | |
| - name: Build | |
| run: pnpm build | |
| - name: Lint | |
| run: pnpm -r lint | |
| - name: Test | |
| env: | |
| CKEDITOR_LICENSE_KEY: ${{ secrets.CKEDITOR_LICENSE }} | |
| run: pnpm test | |
| - name: Playwright Tests | |
| working-directory: tests/playwright | |
| run: | | |
| pnpm exec playwright install --with-deps chromium | |
| pnpm run ui-test | |
| - name: TypeDoc | |
| run: pnpm doc | |
| - name: Publish prerelease | |
| if: github.event_name == 'workflow_dispatch' | |
| run: | | |
| pnpm install --production | |
| echo '//repository.coremedia.com/nexus/repository/coremedia-npm/:_authToken=${NPM_AUTH_TOKEN}' > .npmrc | |
| pnpm publishall --registry=https://repository.coremedia.com/nexus/repository/coremedia-npm/ --no-git-checks --tag pullrequest | |
| # The "Set prerelease version" step pinned all @coremedia/* interdependencies | |
| # to concrete versions so they could be published. Now that publishing is done, | |
| # restore the workspace protocol ("workspace:^<version>") in the committed sources, | |
| # so ongoing development resolves against the local workspace packages. | |
| - name: Restore workspace dependency versions | |
| if: github.event_name == 'workflow_dispatch' | |
| run: | | |
| # Avoid committing the auth token written to .npmrc during publishing. | |
| git checkout -- .npmrc || true | |
| echo "Restoring workspace dependency versions for: ${NEXT_VERSION}" | |
| pnpm run setversion ${NEXT_VERSION} --filter=coremedia/* --dependencyVersion=workspace:^${NEXT_VERSION} | |
| pnpm install --no-frozen-lockfile | |
| git commit -am "ci: Restore workspace dependency versions for ${NEXT_VERSION}" |