diff --git a/.github/actions/README.md b/.github/actions/README.md new file mode 100644 index 000000000..9eb31e00b --- /dev/null +++ b/.github/actions/README.md @@ -0,0 +1,7 @@ +# .github/actions + +Reusable actions for GitHub workflows. + +## [⚙️ Setup](setup/action.yml) + +Setups Node environment and installs dependencies. diff --git a/.github/actions/setup/action.yml b/.github/actions/setup/action.yml new file mode 100644 index 000000000..e9bd12440 --- /dev/null +++ b/.github/actions/setup/action.yml @@ -0,0 +1,18 @@ +name: Setup Node & Install dependencies + +runs: + using: composite + steps: + - uses: pnpm/action-setup@v2 + with: + version: 8.7.6 + + - uses: actions/setup-node@v3 + with: + node-version-file: ".nvmrc" + registry-url: https://registry.npmjs.org + cache: pnpm + + - name: Install dependencies + shell: bash + run: pnpm install --frozen-lockfile diff --git a/.github/workflows/README.md b/.github/workflows/README.md index e0eeea8a4..59ec5e647 100644 --- a/.github/workflows/README.md +++ b/.github/workflows/README.md @@ -1,6 +1,6 @@ # .github/workflows -CI Workflows +CI Workflows. ## [🦄 pr.yml](pr.yml) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index a2b195c47..fd6f84884 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -13,18 +13,8 @@ jobs: steps: - uses: actions/checkout@v3 - - uses: pnpm/action-setup@v2 - with: - version: 8.7.6 - - - uses: actions/setup-node@v3 - with: - node-version-file: ".nvmrc" - registry-url: https://registry.npmjs.org - cache: pnpm - - - name: Install dependencies - run: pnpm install --frozen-lockfile + - name: Setup Node & Install dependencies + uses: ./.github/actions/setup - name: Check linter run: pnpm run lint:check diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 480fc2973..e33886cf5 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -11,24 +11,8 @@ jobs: steps: - uses: actions/checkout@v3 - - uses: pnpm/action-setup@v2 - with: - version: 8.7.6 - - # Fetches the config package version from the `pnpm-lock.yaml` file. - - name: Fetch config package version - id: config-package-version - env: - GITMOJI_CONFIG_PACKAGE: "commitlint-config-gitmoji" - run: | - echo "CONFIG_PACKAGE=$(grep -A 2 "$GITMOJI_CONFIG_PACKAGE" pnpm-lock.yaml | awk '/version:/ {print "'"$GITMOJI_CONFIG_PACKAGE"'@" $2}')" >> "$GITHUB_OUTPUT" - - # Installs only the config package required for commitlint. - - name: Install config package - env: - CONFIG_PACKAGE: "${{ steps.config-package-version.outputs.CONFIG_PACKAGE }}" - run: | - pnpm add -w "$CONFIG_PACKAGE" + - name: Setup Node & Install dependencies + uses: ./.github/actions/setup # The validation is done based on the `commitlint.config.js` file. - name: Validate PR title diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index aa4921a29..b0405cb59 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -13,18 +13,8 @@ jobs: steps: - uses: actions/checkout@v3 - - uses: pnpm/action-setup@v2 - with: - version: 8.7.6 - - - uses: actions/setup-node@v3 - with: - node-version-file: ".nvmrc" - registry-url: https://registry.npmjs.org - cache: pnpm - - - name: Install dependencies - run: pnpm install --frozen-lockfile + - name: Setup Node & Install dependencies + uses: ./.github/actions/setup - name: Build project run: pnpm run build @@ -38,18 +28,8 @@ jobs: steps: - uses: actions/checkout@v3 - - uses: pnpm/action-setup@v2 - with: - version: 8.7.6 - - - uses: actions/setup-node@v3 - with: - node-version-file: ".nvmrc" - registry-url: https://registry.npmjs.org - cache: pnpm - - - name: Install dependencies - run: pnpm install --frozen-lockfile + - name: Setup Node & Install dependencies + uses: ./.github/actions/setup # For now, we only need Chromium. - name: Install browsers for Playwright