Skip to content

Nx migrate

Nx migrate #358

Workflow file for this run

# original source: https://raw.githubusercontent.com/jscutlery/devkit/main/.github/workflows/nx-migrate.yml
name: 'Nx migrate'
on:
workflow_dispatch:
inputs:
logLevel:
required: true
type: string
schedule:
# Every day at 6am UTC
- cron: '0 6 * * *'
jobs:
nx-migrate:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Install dependencies
run: npm install
- name: Check if @nrwl/workspace is outdated
id: nrwl-workspace-outdated
run: |
IS_OUTDATED=$(test ! -z "$(npm outdated @nrwl/workspace)" && echo true || echo false)
echo $IS_OUTDATED
echo "::set-output name=outdated::$IS_OUTDATED"
- name: Update @nrwl/workspace
if: steps.nrwl-workspace-outdated.outputs.outdated == 'true'
run: npx nx migrate latest
- name: Install dependencies
if: steps.nrwl-workspace-outdated.outputs.outdated == 'true'
run: npm install --force
- name: Check if has migrations
id: nrwl-workspace-has-migrations
run: |
HAS_MIGRATIONS=$(test -f migrations.json && echo true || echo false)
echo $HAS_MIGRATIONS
echo "::set-output name=has_migrations::$HAS_MIGRATIONS"
- name: Run @nrwl/workspace migrations
if: steps.nrwl-workspace-has-migrations.outputs.has_migrations == 'true'
run: npx nx migrate --run-migrations
- name: Test
if: steps.nrwl-workspace-outdated.outputs.outdated == 'true'
run: |
npx nx affected -t test --codeCoverage
npx nx affected -t build
- name: Commit changes
if: steps.nrwl-workspace-outdated.outputs.outdated == 'true'
run: |
git add .
[[ $(git status --porcelain) ]] && git commit -m "build: 📦 update nrwl workspace" || echo "nothing to commit"
- name: Remove migrations.json & commit
if: steps.nrwl-workspace-has-migrations.outputs.has_migrations == 'true'
run: |
git rm -f migrations.json
git commit -m "build: 📦 remove migrations.json"
# - name: Push changes
# if: steps.nrwl-workspace-outdated.outputs.outdated == 'true'
# uses: ad-m/github-push-action@master
# with:
# github_token: ${{ secrets.GITHUB_TOKEN }}
# branch: ${{ github.ref }}
# force: true
# tags: true
# Trigger release manually because automated commits
# don't trigger "push" workflows.
#
# Cf. https://docs.github.com/en/actions/security-guides/automatic-token-authentication#using-the-github_token-in-a-workflow
#
# "When you use the repository's GITHUB_TOKEN to perform tasks on behalf of the GitHub Actions app,
# events triggered by the GITHUB_TOKEN will not create a new workflow run.
# This prevents you from accidentally creating recursive workflow runs.""
# - name: Release
# uses: ./.github/actions/release
# with:
# github_token: ${{ secrets.GITHUB_TOKEN }}
# npm_token: ${{ secrets.NPM_TOKEN }}