fix(deps): update all dependencies #12728
This file contains 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: Main workflow | |
# The event triggers are configured as following: | |
# - on branch main, trigger the workflow on every push to trigger production checks and deployment | |
# - on any pull request, trigger the workflow | |
# This is to avoid running the workflow twice on pull requests. | |
on: | |
push: | |
branches: | |
- main | |
merge_group: | |
branches: [main] | |
pull_request: | |
repository_dispatch: | |
types: [manual-build-and-deploy] | |
jobs: | |
build_deploy_test: | |
runs-on: ubuntu-latest | |
# https://github.com/bahmutov/cypress-gh-action-split-install/blob/ca3916d4e7240ebdc337825d2d78eb354855464b/.github/workflows/tests.yml#L8-L11 | |
env: | |
# prevents extra Cypress installation progress messages (github action default is true) | |
CI: 1 | |
# avoid warnings like "tput: No value for $TERM and no -T specified" | |
TERM: xterm | |
# default to being a preview deployment | |
DEPLOY_ENV: Preview | |
steps: | |
- name: Add comment with link to ongoing build | |
uses: marocchino/sticky-pull-request-comment@v2 | |
with: | |
header: -build-status | |
append: true | |
message: | | |
--- | |
**[🏭 A new build process was started - watch live 📺](https://github.com/commercetools/commercetools-docs-kit/actions/runs/${{ github.run_id }})** | |
- name: Detect Production Deploy | |
if: github.event_name == 'push' && github.ref_name == 'main' | |
run: | | |
echo "DEPLOY_ENV=Production" >> $GITHUB_ENV | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Setup Node (uses version in .nvmrc) | |
uses: actions/setup-node@v4 | |
with: | |
node-version-file: '.nvmrc' | |
# cached dependencies | |
- name: Get yarn cache directory path | |
id: yarn-cache-dir-path | |
run: echo "dir=$(yarn config get cacheFolder)" >> $GITHUB_OUTPUT | |
- uses: actions/cache@v4 | |
id: yarn-cache | |
with: | |
path: ${{ steps.yarn-cache-dir-path.outputs.dir }} | |
key: ${{ runner.os }}-yarn-v3-${{ hashFiles('**/yarn.lock') }} | |
restore-keys: | | |
${{ runner.os }}-yarn-v3- | |
# cached build (separately to increase cache efficiency) | |
- uses: actions/cache@v4 | |
id: build-cache | |
with: | |
path: | | |
.cache | |
public | |
key: ${{ runner.os }}-gatsby-monolithic-v2-${{ hashFiles('**/yarn.lock') }} | |
- name: Install dependencies | |
run: yarn install --immutable | |
env: | |
# https://github.com/bahmutov/cypress-gh-action-split-install/blob/ca3916d4e7240ebdc337825d2d78eb354855464b/.github/workflows/tests.yml#L14-L18 | |
# https://github.com/marketplace/actions/cypress-io#custom-install | |
CYPRESS_INSTALL_BINARY: 0 | |
- name: Running static type checking | |
run: yarn typecheck | |
- name: Building Websites | |
run: yarn build | |
env: | |
ENABLE_SEARCH: 'true' | |
NODE_OPTIONS: '--max-old-space-size=6144' | |
GATSBY_EXPERIMENTAL_QUERY_CONCURRENCY: 8 # default is 4, going too high on the 2-core github actions machines will fire back | |
GATSBY_CPU_COUNT: logical_cores # use hyperthreading if available to statistically better saturate the cores | |
- name: GitHub Slug Action | |
uses: rlespinasse/github-slug-action@v4 | |
with: | |
slug-maxlength: 52 | |
- name: Deploy preview to commercetools-docs-kit vercel via CLI | |
if: ${{ env.DEPLOY_ENV == 'Preview' }} | |
id: deploy-to-vercel | |
env: | |
GITHUB_COMMITMESSAGE: ${{ toJSON(github.event.head_commit.message) }} # toJSON is de facto escaping and quoting the string | |
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID}} | |
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID}} | |
run: | | |
vercel deploy --yes --token ${{ secrets.VERCEL_TOKEN }} --scope commercetools -m githubCommitSha=${{ github.sha }} -m githubCommitAuthorName=${{ github.actor }} -m githubCommitAuthorLogin=${{ github.actor }} -m githubDeployment=1 -m githubOrg=commercetools -m githubRepo=commercetools-docs-kit -m githubCommitOrg=commercetools -m githubCommitRepo=commercetools-docs-kit -m githubCommitRef=main -m githubCommitMessage="$GITHUB_COMMITMESSAGE" > deployment-url.txt | |
vercel alias set $(cat deployment-url.txt) docskit-sha-${{ github.sha }}.commercetools.vercel.app --token ${{ secrets.VERCEL_TOKEN }} --scope commercetools | |
vercel alias set $(cat deployment-url.txt) docskit-${{ env.GITHUB_REF_NAME_SLUG_URL }}.commercetools.vercel.app --token ${{ secrets.VERCEL_TOKEN }} --scope commercetools | |
- name: Post new build information | |
if: ${{ env.DEPLOY_ENV == 'Preview' }} | |
uses: marocchino/sticky-pull-request-comment@v2 | |
with: | |
header: -build-status | |
message: | | |
**[🚚 Build Process Details](https://github.com/commercetools/commercetools-docs-kit/actions/runs/${{ github.run_id }})** | |
Preview URLs: | |
* https://docskit-${{ env.GITHUB_REF_NAME_SLUG_URL }}.commercetools.vercel.app _(permalink to the last build of this **branch**)_ | |
* https://docskit-sha-${{ github.sha }}.commercetools.vercel.app _(this **commit**)_ | |
- name: Running linters and tests | |
run: | | |
yarn jest --projects jest.{eslint,test}.config.js \ | |
--maxWorkers=3 \ | |
--reporters jest-silent-reporter | |
yarn percy config:validate | |
- name: Run Writing Style check over Websites | |
run: yarn lint:text | |
- name: Deploy production to commercetools-docs-kit vercel via CLI | |
if: ${{ env.DEPLOY_ENV == 'Production' }} | |
id: deploy-to-vercel-production | |
env: | |
GITHUB_COMMITMESSAGE: ${{ toJSON(github.event.head_commit.message) }} # toJSON is de facto escaping and quoting the string | |
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID}} | |
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID}} | |
run: | | |
vercel deploy --prod --yes --token ${{ secrets.VERCEL_TOKEN }} --scope commercetools -m githubCommitSha=${{ github.sha }} -m githubCommitAuthorName=${{ github.actor }} -m githubCommitAuthorLogin=${{ github.actor }} -m githubDeployment=1 -m githubOrg=commercetools -m githubRepo=commercetools-docs-kit -m githubCommitOrg=commercetools -m githubCommitRepo=commercetools-docs-kit -m githubCommitRef=main -m githubCommitMessage="$GITHUB_COMMITMESSAGE" > deployment-url.txt | |
vercel alias set $(cat deployment-url.txt) docskit-sha-${{ github.sha }}.commercetools.vercel.app --token ${{ secrets.VERCEL_TOKEN }} --scope commercetools | |
- name: Running Visual Regression Tests | |
run: yarn percy snapshot ./public | |
env: | |
PERCY_TOKEN: ${{ secrets.PERCY_TOKEN_SMOKE_TESTS }} | |
# https://github.com/bahmutov/cypress-gh-action-split-install/blob/ca3916d4e7240ebdc337825d2d78eb354855464b/.github/workflows/tests.yml#L23-L30 | |
# https://github.com/marketplace/actions/cypress-io#custom-install | |
- name: Restoring Cypress cache | |
# restore / cache the binary ourselves on Linux | |
# see https://github.com/actions/cache | |
id: cache-cypress | |
uses: actions/cache@v4 | |
with: | |
path: ~/.cache/Cypress | |
key: ${{ runner.os }}-cypress-${{ hashFiles('**/package.json') }} | |
- name: Installing Cypress binary | |
run: yarn cypress install && yarn cypress cache list | |
- name: Running End-to-End tests | |
run: yarn percy exec -- yarn test:e2e:docs-smoke-test --config baseUrl="https://docskit-sha-${{ github.sha }}.commercetools.vercel.app" | |
env: | |
NODE_ENV: test | |
PERCY_TOKEN: ${{ secrets.PERCY_TOKEN_SMOKE_TESTS_E2E }} | |
CYPRESS_CI: 'true' | |
- name: Running API End-to-End tests | |
run: yarn percy exec -- yarn test:e2e:api-docs-smoke-test --config baseUrl="https://docskit-sha-${{ github.sha }}.commercetools.vercel.app" | |
env: | |
NODE_ENV: test | |
PERCY_TOKEN: ${{ secrets.PERCY_TOKEN_API_SMOKE_TESTS_E2E }} | |
CYPRESS_CI: 'true' | |
- name: Check local links including anchors | |
if: ${{ env.DEPLOY_ENV == 'Preview' }} | |
working-directory: public | |
run: npx --quiet start-server-and-test 'npx --quiet http-server --silent -p 9000' http://127.0.0.1:9000 'docker run --platform linux/amd64 --network=host -v "$(pwd)/../:/repo/" tennox/linkcheck --skip-file /repo/linkcheck-local-skip-list :9000' | |
self_learning_test: | |
name: 'Self-learning e2e tests' | |
needs: build_deploy_test | |
runs-on: ubuntu-latest | |
concurrency: self-learning-concurrency-group | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Setup Node (uses version in .nvmrc) | |
uses: actions/setup-node@v4 | |
with: | |
node-version-file: '.nvmrc' | |
# cached dependencies | |
- name: Get yarn cache directory path | |
id: yarn-cache-dir-path | |
run: echo "dir=$(yarn config get cacheFolder)" >> $GITHUB_OUTPUT | |
- uses: actions/cache@v4 | |
id: yarn-cache | |
with: | |
path: ${{ steps.yarn-cache-dir-path.outputs.dir }} | |
key: ${{ runner.os }}-yarn-v3-${{ hashFiles('**/yarn.lock') }} | |
restore-keys: | | |
${{ runner.os }}-yarn-v3- | |
- name: Install dependencies | |
run: yarn install --immutable | |
env: | |
# https://github.com/bahmutov/cypress-gh-action-split-install/blob/ca3916d4e7240ebdc337825d2d78eb354855464b/.github/workflows/tests.yml#L14-L18 | |
# https://github.com/marketplace/actions/cypress-io#custom-install | |
CYPRESS_INSTALL_BINARY: 0 | |
# https://github.com/bahmutov/cypress-gh-action-split-install/blob/ca3916d4e7240ebdc337825d2d78eb354855464b/.github/workflows/tests.yml#L23-L30 | |
# https://github.com/marketplace/actions/cypress-io#custom-install | |
- name: Restoring Cypress cache | |
# restore / cache the binary ourselves on Linux | |
# see https://github.com/actions/cache | |
id: cache-cypress | |
uses: actions/cache@v4 | |
with: | |
path: ~/.cache/Cypress | |
key: ${{ runner.os }}-cypress-${{ hashFiles('**/package.json') }} | |
- name: Installing Cypress binary | |
run: yarn cypress install && yarn cypress cache list | |
- name: Running Self Learning End-to-End tests | |
run: yarn percy exec -- yarn test:e2e:self-learning-smoke-test --config baseUrl="https://docskit-sha-${{ github.sha }}.commercetools.vercel.app" | |
env: | |
NODE_ENV: test | |
PERCY_TOKEN: ${{ secrets.PERCY_TOKEN_SMOKE_TESTS_SELF_LEARNING_E2E }} | |
CYPRESS_CI: 'true' | |
- name: Upload e2e artifacts | |
uses: actions/upload-artifact@v3-node20 | |
if: ${{ failure() }} | |
with: | |
name: self-learning-e2e-failure-snapshots-${{ github.run_attempt }} | |
path: cypress/screenshots/ | |
link-check: | |
name: 'Check links' | |
needs: build_deploy_test | |
if: github.event_name != 'push' && github.ref_name != 'main' | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Check links | |
uses: JustinBeckwith/linkinator-action@v1.11.0 | |
with: | |
paths: https://docskit-sha-${{ github.sha }}.commercetools.vercel.app | |
config: linkinator.remote.config.json | |
markdown: false | |
# the docs production domain has to be rewritten to the preview URL to allow new pages to be created without the link checker | |
# erroring on the canonical URL of the new page. Known compromise to not find links that point to the absolute production URL | |
# but the docs kit is automatically making those a relative URL in authored content so the impact is low. | |
urlRewriteReplace: https://docskit-sha-${{ github.sha }}.commercetools.vercel.app | |
urlRewriteSearch: https://docs.commercetools.com |