-
Notifications
You must be signed in to change notification settings - Fork 2
91 lines (83 loc) · 2.15 KB
/
main.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
name: Codemod publish
on:
push:
paths:
- "codemods/**"
branches:
- main
pull_request:
types:
- closed
paths:
- "codemods/**"
branches:
- main
jobs:
test:
runs-on: ubuntu-24.04
steps:
- name: Checkout Code
uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: pnpm/action-setup@v4
with:
version: 8
- uses: actions/setup-node@v4
with:
node-version: 20
cache: "pnpm"
- name: Check prettier
uses: creyD/[email protected]
with:
dry: True
- name: Install dependencies
run: pnpm install
- name: Run test
run: pnpm recursive run test
publish:
runs-on: ubuntu-24.04
needs: test
steps:
- name: Checkout Code
uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: dorny/paths-filter@v3
id: filter
name: Filter codemods
with:
list-files: shell
filters: |
codemods:
- '**/.codemodrc.json'
- name: export files
run: |
echo "Modified files: ${{steps.filter.outputs.codemods_files}}"
echo "CODEMOD_FILES=${{steps.filter.outputs.codemods_files}}" >> $GITHUB_ENV
echo "Modified status: ${{steps.filter.outputs.codemods}}"
echo "CODEMOD_STATUS=${{steps.filter.outputs.codemods}}" >> $GITHUB_ENV
- uses: pnpm/action-setup@v4
with:
version: 8
- uses: actions/setup-node@v4
with:
node-version: 20
cache: "pnpm"
- name: Install dependencies
run: pnpm install -g codemod
- name: Run publish codemod
run: |
if [ -n "$CODEMOD_STATUS" ]; then
echo "Modified files: $CODEMOD_FILES"
ROOT_DIR=$(pwd)
for FILE in $CODEMOD_FILES; do
DIR=$(dirname "$FILE")
echo "Checking codemod: $DIR"
cd "$ROOT_DIR/$DIR"
pnpm install
echo "Codemod published"
done
else
echo "No codemods found"
fi