Skip to content
This repository has been archived by the owner on May 3, 2024. It is now read-only.

ci: 👷 pin node version #61

ci: 👷 pin node version

ci: 👷 pin node version #61

Workflow file for this run

name: 'Build and Deploy'
permissions:
actions: write
deployments: write
packages: write
pull-requests: write
issues: write
on:
push:
branches:
- main
- next
env:
HUSKY: 0
jobs:
main:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ${{ github.workspace }}
strategy:
matrix:
node-version: [18.17.1]
npm-version: [8.19.2]
yarn-version: ['3.5.x']
pnpm-version: [8.1.0]
steps:
- name: Checkout [Pull Request]
uses: actions/checkout@v3
if: ${{ github.event_name == 'pull_request' }}
with:
ref: ${{ github.event.pull_request.head.sha }}
token: ${{ secrets.GH_TOKEN }}
fetch-depth: 0
- name: Checkout [Default Branch]
uses: actions/checkout@v3
if: ${{ github.event_name != 'pull_request' }}
with:
token: ${{ secrets.GH_TOKEN }}
fetch-depth: 0
- name: Derive appropriate SHAs for base and head for `nx affected` commands
uses: nrwl/nx-set-shas@v2
with:
main-branch-name: ${{ github.base_ref }}
- name: Detect package manager
id: package_manager
run: |
echo "::set-output name=name::$([[ -f ./yarn.lock ]] && echo "yarn" || ([[ -f ./pnpm-lock.yaml ]] && echo "pnpm") || echo "npm")"
- name: Set node/npm/yarn versions using volta
uses: volta-cli/action@v4.0.0
with:
node-version: '${{ matrix.node-version }}'
npm-version: '${{ matrix.npm-version }}'
yarn-version: '${{ matrix.yarn-version }}'
- name: Install PNPM
if: steps.package_manager.outputs.name == 'pnpm'
uses: pnpm/action-setup@v2.2.1
with:
version: '${{ matrix.pnpm-version }}'
- name: Print node/npm/yarn/pnpm versions
id: versions
run: |
node_ver=$( node --version )
yarn_ver=$( yarn --version || true )
pnpm_ver=$( pnpm --version || true )
echo "Node: ${node_ver:1}"
echo "NPM: $(npm --version )"
if [[ $yarn_ver != '' ]]; then echo "Yarn: $yarn_ver"; fi
if [[ $pnpm_ver != '' ]]; then echo "PNPM: $pnpm_ver"; fi
echo "::set-output name=node_version::${node_ver:1}"
- name: Use the node_modules cache if available [npm]
if: steps.package_manager.outputs.name == 'npm'
uses: actions/cache@v2
with:
path: '**/node_modules'
key: ${{ runner.os }}-modules-${{ hashFiles('**/package-lock.json') }}
- name: Use the node_modules cache if available [pnpm]
if: steps.package_manager.outputs.name == 'pnpm'
uses: actions/cache@v2
with:
path: '**/node_modules'
key: ${{ runner.os }}-modules-${{ hashFiles('**/pnpm-lock.yaml') }}
- name: Get yarn cache directory path
if: steps.package_manager.outputs.name == 'yarn'
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
- name: Use the node_modules cache if available [yarn]
if: steps.package_manager.outputs.name == 'yarn'
uses: actions/cache@v2
with:
path: '**/node_modules'
key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }}
- name: Install dependencies
run: |
if [ "${{ steps.package_manager.outputs.name == 'yarn' }}" == "true" ]; then
echo "Running yarn install --frozen-lockfile"
yarn install --frozen-lockfile
elif [ "${{ steps.package_manager.outputs.name == 'pnpm' }}" == "true" ]; then
echo "Running pnpm install --frozen-lockfile"
pnpm install --frozen-lockfile
else
echo "Running npm ci"
npm ci
fi
- name: Checks
run: |
npx nx affected --target lint --parallel 4 --exclude demo
npx nx affected --target test --parallel 4 --ci --exclude demo
- name: Release
if: ${{ success() && (github.event_name != 'pull_request' || github.event.action == 'closed' && github.event.pull_request.merged == true) }}
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
NODE_AUTH_TOKEN: ${{ secrets.GH_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
run: |
npx nx affected --target semantic-release --parallel 4 --exclude demo