Skip to content

dependency

dependency #1438

Workflow file for this run

name: Yarn build and Publish to another repo
on:
workflow_dispatch:
repository_dispatch:
types: [dependency]
push:
branches: [master]
pull_request:
branches: [master]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: true
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: '18'
- name: Prepare static
run: |
git clone https://github.com/mirrorz-org/mirrorz-json-legacy.git static/json/json-legacy
mv static/json/json-legacy/data static/json/legacy
rm -rf static/json/json-legacy
git clone https://github.com/mirrorz-org/mirrorz-json-site.git static/json/site
- name: Prepare parser, config, i18n, oh-my-mirrorz
run: |
git clone https://github.com/mirrorz-org/mirrorz-parser.git src/parser
git clone https://github.com/mirrorz-org/mirrorz-config.git src/config
git clone https://github.com/mirrorz-org/mirrorz-i18n.git src/i18n
yarn mirrorz_env
git clone https://github.com/mirrorz-org/oh-my-mirrorz.git scripts/oh-my-mirrorz
- name: Prepare legacy
run: |
git clone https://github.com/mirrorz-org/mirrorz-legacy.git legacy
yarn legacy_env
- name: Install dependencies
run: yarn --frozen-lockfile
- name: Install legacy dependencies
run: |
cd legacy
yarn --frozen-lockfile
cd ..
- name: Build
run: |
yarn build
yarn legacy_build
yarn ohmymirrorz_build
mkdir -p drop
tar -czf drop/dist.tar.gz dist
- name: Upload dist package as artifact
uses: actions/upload-artifact@v3
with:
name: dist
path: drop/dist.tar.gz
retention-days: 3
screenshots:
name: Visual diff
if: ${{ false }} # TODO: disable for now. Should provide a mock env
runs-on: ubuntu-latest
needs:
- build
steps:
- uses: actions/checkout@v4
with:
submodules: true
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: '14'
- name: Install dependencies
run: |
yarn --frozen-lockfile
npx playwright install-deps
npx playwright install
- name: Download dist package
uses: actions/download-artifact@v3
with:
name: dist
- name: Unzip dist package
run: |
tar xzf dist.tar.gz
- name: Update snapshot baseline
if: ${{ github.ref == 'refs/heads/master' }}
run: |
yarn test --update-snapshots
- name: Upload screenshot baseline as artifacts
if: ${{ github.ref == 'refs/heads/master' }}
uses: actions/upload-artifact@v3
with:
name: screenshot-baseline
path: |
tests/*-snapshots
- name: Download baseline and take screenshots
if: ${{ github.ref != 'refs/heads/master' }}
run: |
yarn download-snapshot-baseline snapshot-baseline.zip
unzip -o snapshot-baseline.zip -d tests
yarn test
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Upload screenshot differences as artifacts
if: ${{ github.ref != 'refs/heads/master' && always() }}
uses: actions/upload-artifact@v3
with:
name: screenshots
path: |
tests/*-snapshots
test-results
retention-days: 3
deploy:
runs-on: ubuntu-latest
if: ${{ github.ref == 'refs/heads/master' }}
needs:
- build
steps:
- uses: actions/checkout@v4
with:
submodules: true
- name: Download dist package
uses: actions/download-artifact@v3
with:
name: dist
- name: Commit and publish
env:
ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }}
PUBLISH_REPOSITORY: ${{ secrets.PUBLISH_REPOSITORY }}
run: |
tar xzf dist.tar.gz
remote_repo="https://x-access-token:${ACCESS_TOKEN}@github.com/${PUBLISH_REPOSITORY}.git"
remote_branch="master"
git_commit_id=$(git rev-parse --short HEAD)
mkdir _site_remote && cd _site_remote
git init
git config user.name "Mirrorz Bot"
git config user.email "bot@mirrorz.org"
git remote add origin $remote_repo
git pull origin $remote_branch
git rm -rf .
git clean -fxd
cp -ar ../dist/* ./
touch .nojekyll
git add .
git commit -m "Github Action auto build for https://github.com/tuna/mirrorz/commit/${git_commit_id}" --allow-empty
git push -u origin $remote_branch