Skip to content

gha(deps): bump actions/checkout from 3 to 4 #94

gha(deps): bump actions/checkout from 3 to 4

gha(deps): bump actions/checkout from 3 to 4 #94

name: CI/CD. Create React App
on:
push:
branches:
# matches every branch that doesn't contain a '/'
# - '*'
# matches every branch containing a single '/'
# - '*/*'
# matches every branch
- '**'
# excludes master
# - '!master'
# includes one
# - 'my-created-react-app'
paths:
# Include this workflow
- '.github/workflows/ci.create-react-app.yml'
# Include target folder
- 'my-created-react-app/**'
pull_request:
types: [opened, synchronize, reopened]
branches:
- '**'
paths:
- '.github/workflows/ci.create-react-app.yml'
- 'my-created-react-app/**'
# manual dispatch
workflow_dispatch:
#defaults:
# run:
# shell: bash
# working-directory: my-created-react-app
jobs:
avoid_reduncy:
runs-on: ubuntu-18.04
steps:
- name: Cancel Previous Redundant Builds
uses: styfle/cancel-workflow-action@0.11.0
build-created-react-app:
name: Node ${{ matrix.node_version }} ${{ matrix.architecture }} on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
env:
working-directory: ./my-created-react-app
strategy:
matrix:
os:
- ubuntu-18.04
# - ubuntu-20.04
# - ubuntu-latest
# - windows-latest
node_version:
# - 12.x
# - 14.x
- 16.x
# - 18.x
architecture:
- x64
# # an extra windows-x86 run:
# include:
# - os: windows-2016
# node_version: 12
# architecture: x86
steps:
- name: Echo. Cwd - Working Directory
uses: actions/github-script@v5
with:
result-encoding: string
script: |
const path = require('path');
console.log("path: ", path.resolve('.'));
console.log("CWD: ", process.cwd());
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node_version }}
architecture: ${{ matrix.architecture }}
check-latest: true
# zero-config caching available using setup-node@v2
# cache: 'npm'
- name: Echo. node version
run: node --version
- name: Echo. npm version
run: npm --version
# - name: Upgrade npm
# run: npm install -g npm
# - name: Echo. node version
# run: node --version
# - name: Echo. npm version
# run: npm --version
# Always after setup node/npm or use `actions/setup-node.with.cache: 'npm'`
# verbose caching if using `actions/setup-node@v1`
- name: Determine npm cache directory
id: npm-cache-dir
run: |
echo "dir=$(npm config get cache)" \
>> $GITHUB_OUTPUT
- name: Handle npm cache
uses: actions/cache@v3
# use this to check for `cache-hit` ==> if: steps.npm-cache.outputs.cache-hit != 'true'
id: npm-cache
with:
path: ${{ steps.npm-cache-dir.outputs.dir }}
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
${{ runner.os }}-node-
${{ runner.os }}-
- name: Echo. npm cache status
env:
NPM_CACHE_DIR: ${{ steps.npm-cache-dir.outputs.dir }}
NPM_CACHE_HIT: ${{ steps.npm-cache.outputs.cache-hit }}
RUNNER_OSPLAT: ${{ runner.os }}
shell: bash
run: |
echo $RUNNER_OSPLAT
echo $NPM_CACHE_DIR
echo $NPM_CACHE_HIT
- name: Echo. Git status
run: git status
- name: Echo. List CWD folder
run: ls -lAoghi1
- name: Init React app project
run: npx create-react-app my-created-react-app --use-npm
- name: Echo. Git status
run: git status
- name: Echo. List CWD folder
run: ls -lAoghi1
- name: Echo. List folder ${{ env.working-directory }}
working-directory: ${{ env.working-directory }}
run: ls -lAoghi1
# - name: Build React app project
# working-directory: ${{ env.working-directory }}
# run: npm ci
- name: Echo. Git status
run: git status
- name: Echo. List folder ${{ env.working-directory }}
working-directory: ${{ env.working-directory }}
run: ls -lAoghi1