From 6f44a364fafe8e06df9ccc9cacada78975af1637 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20G=C3=B3ral?= Date: Fri, 21 Feb 2025 16:28:05 +0700 Subject: [PATCH] docs: describe a setup action on a higher level --- .../4.deployment/8.ci-cd.md | 101 +++++++----------- 1 file changed, 38 insertions(+), 63 deletions(-) diff --git a/docs/content/guides/6.multistore/2.tooling-and-concepts/4.deployment/8.ci-cd.md b/docs/content/guides/6.multistore/2.tooling-and-concepts/4.deployment/8.ci-cd.md index 4f852301b0..ccf6c63d10 100644 --- a/docs/content/guides/6.multistore/2.tooling-and-concepts/4.deployment/8.ci-cd.md +++ b/docs/content/guides/6.multistore/2.tooling-and-concepts/4.deployment/8.ci-cd.md @@ -41,78 +41,53 @@ Let's look at how continuous integration works in a multistore setup, using GitH First, we need to set up the environment. Our setup action handles several crucial steps: ::tip Why a Separate Setup Action? -We use a separate setup action to follow the DRY (Don't Repeat Yourself) principle, as these setup steps are used in multiple workflows - for instance `continuous-integration.yml` and `continuous-deployment.yml`. However, you can include these steps directly in your workflow if you prefer - there's no technical requirement to have them as a separate action. +We use a separate setup action to follow the DRY (Don't Repeat Yourself) principle, as these setup steps are used in multiple workflows. We've implemented it as a [composite action](https://docs.github.com/en/actions/sharing-automations/creating-actions/creating-a-composite-action) to make it reusable across different workflows. :: -Here's how our setup action is defined: +The Setup action performs these steps in sequence: -```yaml -name: Setup repository -description: Installs all the packages and initializes environment variables +1. **Node.js Setup** + - Uses Node.js version specified in `.nvmrc` file -# Define required inputs for npm registry authentication -inputs: - npm_user: - description: Enterprise NPM registry user - required: true - npm_password: - description: Enterprise NPM registry password - required: true - npm_email: - description: Enterprise NPM registry email - required: true +2. **Cache Configuration** + - Sets up Yarn cache for `node_modules` directory to speed up installations + - Configures Turbo build cache for faster builds. Read more about Turbo CI caching [here](https://turbo.build/repo/docs/guides/ci-vendors). -runs: - using: composite - steps: - - name: Set up Node.js - uses: actions/setup-node@v4 - with: - node-version-file: ./.nvmrc - - # Configure Yarn cache to speed up installations - - name: Yarn cache - uses: actions/cache@v4 - with: - path: .yarn - key: storefront-yarn-cache - - # Set up Turbo cache for faster builds - - name: Cache turbo build setup - uses: actions/cache@v4 - with: - path: .turbo - key: starter-turbo-${{ github.sha }} - restore-keys: | - starter-turbo- - - # Configure access to private npm registry - - name: Configure NPM registry - shell: bash - run: | - npm install -g npm-cli-login; - npm-cli-login -u ${{ inputs.npm_user }} -p ${{ inputs.npm_password }} -e ${{ inputs.npm_email }} -r https://registrynpm.storefrontcloud.io || exit 1; - - # Install all project dependencies - - name: Install dependencies - shell: bash - # We use frozen-lockfile to ensure consistent dependencies across all environments - # This is important for CI/CD to avoid unexpected issues - # We run init.mjs to ensure the project is properly initialized - run: yarn install --frozen-lockfile --cache-folder .yarn && node init.mjs -``` +3. **NPM Registry Access** + - Configures access to private npm registry + - Uses provided credentials for authentication + ```bash + # Install npm-cli-login globally + npm install -g npm-cli-login + + # Configure access to Alokai Enterprise Registry + npm-cli-login \ + -u $NPM_USER \ + -p $NPM_PASSWORD \ + -e $NPM_EMAIL \ + -r "https://registrynpm.storefrontcloud.io" + + # You can verify the configuration by running the following command: + npm config get @alokai:registry + # Should return: https://registrynpm.storefrontcloud.i + ``` + +4. **Dependencies Installation** + - Installs project dependencies using Yarn + - Uses frozen lockfile for consistency + - Runs initialization script + ```bash + # Install dependencies with frozen lockfile + yarn install --frozen-lockfile --cache-folder .yarn + + # Run initialization script + node init.mjs + ``` -And here's how we use it in our workflow: +Here's how to use it in your workflow: ```yaml steps: - # 1. Check out your code - - name: Checkout code - uses: actions/checkout@v4 - with: - fetch-depth: 0 # Important: Need full git history for change detection - - # 2. Set up environment using our custom action - name: Install dependencies uses: ./.github/actions/setup with: