Skip to content

Commit 08a93a7

Browse files
committed
feat(nx-migrate-action): add github action to perform nx migrations
closed COD-128
1 parent 3602c8b commit 08a93a7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

76 files changed

+5333
-507
lines changed

.actrc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
-P ubuntu-latest=catthehacker/ubuntu:act-latest
2+
--container-architecture linux/amd64

.env.local

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
NX_NO_CLOUD=true
1+
ACTIONS_STEP_DEBUG=true
2+
NX_NO_CLOUD=true

.github/workflows/README.md

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
# Running GitHub Actions Workflows Locally
2+
3+
## Getting Started
4+
5+
### Install `act`
6+
7+
#### macOS
8+
9+
```sh
10+
brew install act
11+
```
12+
13+
#### Linux
14+
15+
```sh
16+
curl https://raw.githubusercontent.com/nektos/act/master/install.sh | sudo bash
17+
```
18+
19+
#### Windows (with Chocolatey)
20+
21+
```powershell
22+
choco install act-cli
23+
```
24+
25+
> Remove or change `--container-architecture` in `.actrc` file.
26+
27+
### Secrets & Variables
28+
29+
Copy `.secrets.example` to `.secrets`.
30+
31+
Create your own PAT for test and replace the value for `GITHUB_TOKEN`.
32+
33+
- [Classic tokens](https://github.com/settings/tokens)
34+
- [Fine-grained tokens](https://github.com/settings/tokens?type=beta)
35+
36+
`.vars` contains the variables used by the workflows.
37+
38+
Add more or update values in these files when needed.
39+
40+
## TLDR
41+
42+
```sh
43+
# Validate `nx-migrate.yml`
44+
act schedule -n -j nx-migrate
45+
46+
# Run `nx-migrate.yml` with local env file applied
47+
act schedule --env-file .env.local -j nx-migrate
48+
```
49+
50+
## Basic Usage
51+
52+
```sh
53+
# Run all workflows
54+
act
55+
56+
# Run a specific workflow
57+
act -W .github/workflows/specific-workflow.yml
58+
59+
# List all available actions
60+
act -l
61+
62+
# Run a specific event
63+
act push
64+
```
65+
66+
## Common Options
67+
68+
```sh
69+
# Dry run
70+
act -n
71+
72+
# Enable verbose logging
73+
act -v
74+
75+
# Use workspace local env file instead of default `.env`
76+
act --env-file .env.local
77+
78+
# Run workflow with specific inputs
79+
act workflow_dispatch -i input1=value1 -i input2=value2
80+
```
81+
82+
## Debugging Tips
83+
84+
### Use `-v` flag for verbose output
85+
86+
```sh
87+
act -v
88+
```
89+
90+
### Check container logs
91+
92+
```sh
93+
docker logs $(docker ps -q --filter ancestor=catthehacker/ubuntu:act-latest)
94+
```
95+
96+
### Interactive debugging
97+
98+
```sh
99+
act -i
100+
```

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,13 @@ jobs:
3737
node-version: 'lts/*'
3838
cache: 'pnpm'
3939

40-
- run: pnpm nx-cloud start-ci-run --distribute-on="3 linux-small-js" --stop-agents-after="e2e-ci"
40+
- run: pnpx nx-cloud start-ci-run --distribute-on="3 linux-small-js" --stop-agents-after="e2e-ci"
4141
if: ${{ vars.NX_NO_CLOUD != 'true' }}
4242

4343
- run: pnpm install --frozen-lockfile
4444
- uses: nrwl/nx-set-shas@v4
4545

46-
- run: pnpm nx-cloud record -- nx format:check
46+
- run: pnpx nx-cloud record -- nx format:check
4747
if: ${{ vars.NX_NO_CLOUD != 'true' }}
4848
shell: bash
4949

.github/workflows/nx-migrate.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: Nx migrate
2+
3+
on:
4+
workflow_dispatch:
5+
schedule:
6+
# Every day at 6am UTC
7+
- cron: '0 6 * * *'
8+
9+
permissions:
10+
contents: write
11+
pull-requests: write
12+
13+
jobs:
14+
nx-migrate:
15+
runs-on: ubuntu-latest
16+
17+
steps:
18+
- uses: actions/checkout@v4
19+
20+
- uses: pnpm/action-setup@v2
21+
with:
22+
version: latest
23+
24+
- uses: actions/setup-node@v4
25+
with:
26+
node-version: 'lts/*'
27+
cache: 'pnpm'
28+
29+
- name: Install dependencies
30+
run: pnpm install --frozen-lockfile
31+
32+
- name: Build action
33+
run: pnpm nx build nx-migrate-action
34+
35+
- name: Run Nx migrate
36+
uses: ./packages/nx-migrate-action
37+
with:
38+
token: ${{ secrets.GITHUB_TOKEN }}
39+
auto-merge: ${{ vars.NX_AUTO_MIGRATE }}
40+
check-token: ${{ vars.NX_MIGRATE_CHECK_TOKEN }}
41+
skip-e2e: ${{ vars.NX_MIGRATE_SKIP_E2E }}
42+
dry-run: ${{ vars.NX_MIGRATE_DRY_RUN }}

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ yarn.lock
3030
!.vscode/extensions.json
3131

3232
# misc
33+
/.pnpm-store
3334
/.sass-cache
3435
/.pnpm-store
3536
/connect.lock
@@ -50,3 +51,6 @@ Thumbs.db
5051
migrations.json
5152

5253
**/vite.config.{js,ts,mjs,mts,cjs,cts}.timestamp*
54+
55+
# Act
56+
.secrets

.nx/workflows/agents.yaml

Lines changed: 0 additions & 30 deletions
This file was deleted.

.secrets.example

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
GITHUB_TOKEN=your_test_token_here

.vars

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# .github/workflows/nx-migrate.yml
2+
NX_AUTO_MIGRATE=false
3+
NX_MIGRATE_CHECK_TOKEN=true
4+
NX_MIGRATE_SKIP_E2E=true
5+
NX_MIGRATE_DRY_RUN=false

.verdaccio/config.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# path to a directory with all packages
2+
storage: ../tmp/local-registry/storage
3+
4+
# a list of other known repositories we can talk to
5+
uplinks:
6+
npmjs:
7+
url: https://registry.npmjs.org/
8+
maxage: 60m
9+
10+
packages:
11+
'**':
12+
# give all users (including non-authenticated users) full access
13+
# because it is a local registry
14+
access: $all
15+
publish: $all
16+
unpublish: $all
17+
18+
# if package is not available locally, proxy requests to npm registry
19+
proxy: npmjs
20+
21+
# log settings
22+
log:
23+
type: stdout
24+
format: pretty
25+
level: warn
26+
27+
publish:
28+
allow_offline: true # set offline to true to allow publish offline

0 commit comments

Comments
 (0)