feat: init lint-staged and husky #4
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: Build Master | |
on: | |
push: | |
branches: ['master'] | |
paths-ignore: | |
- '**/*.tgz' | |
- '**/*.gz' | |
- '**/release/**' | |
- '**garbage-collector**' | |
- '**codeql**' | |
pull_request: | |
branches: ['master'] | |
types: | |
- closed | |
paths-ignore: | |
- '**/release/**' | |
- '**/*.tgz' | |
- '**/*.gz' | |
- '**/test*/**' | |
workflow_dispatch: | |
permissions: write-all | |
# run single job | |
concurrency: | |
group: build-master | |
cancel-in-progress: true | |
jobs: | |
packer: | |
runs-on: ${{ matrix.os }} | |
# set timeout - see https://stackoverflow.com/a/59076067/6404439 | |
timeout-minutes: 120 | |
strategy: | |
matrix: | |
os: [ubuntu-latest, windows-latest, macos-latest] | |
node-version: ['14.x', '16.x', '18.x'] | |
fail-fast: false | |
#max-parallel: 3 | |
env: | |
NODE_OPTIONS: '--max_old_space_size=8192' #8192 4096 --expose-gc | |
YARN_ENABLE_IMMUTABLE_INSTALLS: false | |
ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }} | |
steps: | |
- run: git config --global core.autocrlf false | |
- uses: szenius/set-timezone@v1.2 | |
name: set os timezone | |
with: | |
timezoneLinux: 'Asia/Jakarta' | |
timezoneMacos: 'Asia/Jakarta' | |
timezoneWindows: 'Indonesia Standard Time' | |
- name: Checkout repository and submodules | |
uses: actions/checkout@v3 | |
with: | |
submodules: recursive | |
token: '${{ secrets.ACCESS_TOKEN }}' | |
ref: 'master' | |
- name: update submodules | |
run: | | |
mkdir bin | |
curl -L https://github.com/dimaslanjaka/bin/raw/master/bin/submodule-install > bin/submodule-install | |
bash ./bin/submodule-install | |
shell: bash | |
- name: Use Node.js ${{ matrix.node-version }} | |
uses: actions/setup-node@v3 | |
with: | |
node-version: ${{ matrix.node-version }} | |
- name: Enable corepack | |
shell: bash | |
run: corepack enable | |
- name: Set env | |
id: set-env | |
shell: bash | |
run: | | |
echo "${HOME}/.local/bin" >> $GITHUB_PATH | |
echo "${GITHUB_WORKSPACE}/bin" >> $GITHUB_PATH | |
echo "${GITHUB_WORKSPACE}/node_modules/.bin" >> $GITHUB_PATH | |
echo "GITHUB_SHA_SHORT=$(echo $GITHUB_SHA | cut -c 1-6)" >> $GITHUB_ENV | |
echo "GITHUB_SHA_SHORT=$(echo $GITHUB_SHA | cut -c 1-6)" >> $GITHUB_OUTPUT | |
echo "GITHUB_BRANCH=${GITHUB_REF#refs/heads/}" >> $GITHUB_ENV | |
echo "GITHUB_BRANCH=${GITHUB_REF#refs/heads/}" >> $GITHUB_OUTPUT | |
echo "GITHUB_COMMIT_URL=https://github.com/${{github.repository}}/commit/$(echo $GITHUB_SHA)" >> $GITHUB_ENV | |
echo "GITHUB_COMMIT_URL=https://github.com/${{github.repository}}/commit/$(echo $GITHUB_SHA)" >> $GITHUB_OUTPUT | |
echo "GITHUB_RUNNER_URL=https://github.com/${{github.repository}}/commit/${{github.sha}}/checks/${{github.run_id}}" >> $GITHUB_ENV | |
echo "GITHUB_RUNNER_URL=https://github.com/${{github.repository}}/commit/${{github.sha}}/checks/${{github.run_id}}" >> $GITHUB_OUTPUT | |
echo "CACHE_NPM=$(npm config get cache)" >> $GITHUB_ENV | |
echo "cache-npm=$(npm config get cache)" >> $GITHUB_OUTPUT | |
YARN_CURRENT=$(yarn -v) | |
YARN_BERRY=3.2.1 | |
if [[ "ok" == "$(echo | awk "(${YARN_CURRENT} > ${YARN_BERRY}) { print \"ok\"; }")" ]]; then | |
echo "CACHE_YARN=$(yarn config get cacheFolder)" >> $GITHUB_ENV | |
echo "cache-yarn=$(yarn config get cacheFolder)" >> $GITHUB_OUTPUT | |
else | |
echo "CACHE_YARN=$(yarn cache dir)" >> $GITHUB_ENV | |
echo "cache-yarn=$(yarn cache dir)" >> $GITHUB_OUTPUT | |
fi | |
echo "architecture=$(getconf LONG_BIT)" >> $GITHUB_ENV | |
- uses: pat-s/always-upload-cache@v3.0.11 | |
id: cache | |
with: | |
path: | | |
**/.yarn | |
./releases | |
./yarn.lock | |
./releases/yarn.lock | |
**/node_modules | |
**/tmp | |
**/dist | |
key: ${{ runner.os }}-${{ matrix.node-version }}-${{ github.ref_name }} | |
restore-keys: | | |
${{ runner.os }}-${{ matrix.node-version }}-${{ github.ref_name }} | |
${{ runner.os }}-${{ matrix.node-version }}- | |
${{ runner.os }}- | |
- name: Install Dependencies | |
run: | | |
touch yarn.lock | |
yarn install | |
npm run prepare | |
shell: bash | |
#timeout-minutes: 60 | |
- name: Build | |
run: npm run build | |
shell: bash | |
id: build | |
- run: git add release | |
- run: git add dist | |
- name: what changes | |
id: changes | |
shell: bash | |
run: | | |
git status | |
echo "" | |
countChanges=$(git whatchanged -1 --format=oneline | wc -l) | |
echo "total changed files is $countChanges" | |
countStaged=$(git diff --cached --numstat | wc -l) | |
echo "total staged files is $countStaged" | |
countCommits=$(git diff origin/master..HEAD --numstat | wc -l) | |
echo "total unpushed commits is $countCommits" | |
countReleases=$(git diff --numstat -- releases | wc -l) | |
echo "total releases changed is $countReleases" | |
echo "staged=$(countStaged)" >> $GITHUB_OUTPUT | |
echo "commits=$(git diff origin/master..HEAD --numstat | wc -l)" >> $GITHUB_OUTPUT | |
echo "releases=$(git diff --numstat -- releases | wc -l)" >> $GITHUB_OUTPUT | |
- name: Push | |
if: matrix.node-version == '18.x' && runner.os == 'Linux' && steps.build.outcome == 'success' && steps.changes.outputs.staged != '0' | |
run: | | |
git config --global user.name 'dimaslanjaka' | |
git config --global user.email 'dimaslanjaka@gmail.com' | |
git add releases | |
git commit -m "Update build from ${{ steps.set-env.outputs.GITHUB_COMMIT_URL }}" -m "commit hash: ${{ steps.set-env.outputs.GITHUB_SHA_SHORT }}" -m "commit url: ${{ steps.set-env.outputs.GITHUB_COMMIT_URL }}" -m "runner: ${{ steps.set-env.outputs.GITHUB_RUNNER_URL }}" | |
git push |