Skip to content

Commit

Permalink
chore(ci): add "publish" GHA
Browse files Browse the repository at this point in the history
  • Loading branch information
JakobJingleheimer committed Dec 12, 2024
1 parent c875d81 commit 05054f7
Showing 1 changed file with 59 additions and 0 deletions.
59 changes: 59 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: Publish to codemod registry

on:
push:
branches: ["main"]
paths: ["recipes/**"]
pull_request:
types: [closed]
paths: ["recipes/**"]
branches: ["main"]

jobs:
publish:
runs-on: ubuntu-latest

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: actions/setup-node@v4
with:
node-version: node
cache: 'npm'
- name: Install "codemod" binary
run: npm install 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"
npx codemod publish
echo "Codemod published"
done
else
echo "No codemods found"
fi

0 comments on commit 05054f7

Please sign in to comment.