Skip to content

shim hexo.page with SiteLocals and PageSchema #341

shim hexo.page with SiteLocals and PageSchema

shim hexo.page with SiteLocals and PageSchema #341

name: Workspace Build Release
on:
push:
branches: ['monorepo-v7', 'v7-yarn-v3']
paths-ignore:
- '**/*.tgz'
- '**/*.gz'
- '**/release*/**'
- '**garbage-collector**'
- '**codeql**'
pull_request:
branches: ['monorepo-v7', 'v7-yarn-v3']
types:
- closed
paths-ignore:
- '**/release*/**'
- '**/*.tgz'
- '**/*.gz'
- '**/test*/**'
workflow_dispatch:
permissions: write-all
# run single job
concurrency:
group: build-workspace
cancel-in-progress: true
jobs:
build_win_node14:
name: Build Windows Node 14.x
uses: ./.github/workflows/workspace-builder.yml
secrets:
ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }}
with:
os: windows-latest
node-version: 14.x
test_win_node14:
needs: build_win_node14
name: Test Windows Node 14.x
uses: ./.github/workflows/workspace-tester.yml
secrets:
ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }}
with:
os: windows-latest
node-version: 14.x
pack:
needs: build_win_node14
runs-on: windows-latest
# set timeout - see https://stackoverflow.com/a/59076067/6404439
timeout-minutes: 120
strategy:
fail-fast: true
env:
NODE_OPTIONS: '--max_old_space_size=8192' #8192 4096 --expose-gc
YARN_ENABLE_IMMUTABLE_INSTALLS: false
ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }}
node_version: 14.x
steps:
- run: git config --global core.autocrlf false
- name: Checkout repository and submodules
uses: actions/checkout@v3
with:
submodules: recursive
token: '${{ secrets.ACCESS_TOKEN }}'
ref: 'monorepo-v7'
- name: update submodules
run: |
echo "init submodules"
git submodule init
git submodule foreach "git submodule init"
echo "sync submodules"
git submodule sync
git submodule foreach "git submodule sync"
echo "update submodules"
mkdir -p bin >/dev/null 2>&1
curl -L https://github.com/dimaslanjaka/bin/raw/master/bin/submodule-install > bin/submodule-install
rm -rf .git/modules
bash ./bin/submodule-install
echo "disable githooks warning"
git config advice.ignoredHook false
git config core.eol lf
git config core.autocrlf input
git checkout-index --force --all
shell: bash
- name: Use Node.js ${{ env.node_version }}
uses: actions/setup-node@v3
with:
node-version: ${{ env.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: actions/cache/restore@v3
id: cache
with:
path: '**/*'
key: ${{ runner.os }}-${{ env.node_version }}
- name: Download build-output artifact
uses: actions/download-artifact@master
with:
name: build-output
- name: Install Dependencies
run: yarn install
shell: bash
- run: bash -e ./bin/validate-tarball
- name: modify releases
shell: bash
run: |
git config --global user.name 'dimaslanjaka'
git config --global user.email 'dimaslanjaka@gmail.com'
git add releases
echo "undo staged releases/readme.md"
git restore --staged releases/readme.md
hasChanged=$(git diff --cached --numstat -- releases | wc -l)
echo "changes $hasChanged"
if [ $hasChanged -ge 0 ]; then
git commit -m "chore(tarball): build ${{ steps.set-env.outcome.GITHUB_COMMIT_URL }}"
lastcommit=$(git rev-parse --short HEAD)
sed -i "s/<production>/$lastcommit/g" releases/readme.md
git add releases
hasChanged=$(git diff --cached --numstat -- releases | wc -l)
echo "changes $hasChanged"
if [ $hasChanged -ge 0 ]; then
git commit -m "docs: update releases docs"
fi
fi
- name: what changes
id: changes
shell: bash
run: |
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/${{ steps.set-env.outputs.GITHUB_BRANCH }}..HEAD --numstat | wc -l)
echo "total unpushed commits is $countCommits"
if [ -d "releases" ]; then
countReleases=$(git diff --numstat -- releases | wc -l)
else
countReleases=$(git diff --numstat -- release | wc -l)
fi
echo "total releases changed is $countReleases"
echo "staged=$countStaged" >> $GITHUB_OUTPUT
echo "commits=$countCommits" >> $GITHUB_OUTPUT
echo "releases=$countReleases" >> $GITHUB_OUTPUT
git status --porcelain
- name: Push
if: steps.changes.outputs.commits > 0
run: |
git config --global user.name 'dimaslanjaka'
git config --global user.email 'dimaslanjaka@gmail.com'
git pull -X theirs
git push