-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add codemod publish workflow #50
Merged
alexbit-codemod
merged 4 commits into
nodejs:main
from
amirabbas-gh:codemod_publish_workflow
Apr 9, 2025
+108
−0
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
0a6c02f
feat: add codemod publish workflow
amirabbas-gh a998731
refactor: using npm insted of pnpm
amirabbas-gh 77cc673
refactor: using node version file for setup node in publish workflow
amirabbas-gh 7d561c1
refactor: improve security using Stepsecurity
amirabbas-gh File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
name: Codemod publish | ||
|
||
on: | ||
workflow_dispatch: | ||
push: | ||
paths: | ||
- "recipes/**" | ||
- "codemods/**" | ||
branches: | ||
- main | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
paths-filter: | ||
permissions: | ||
contents: read | ||
pull-requests: read | ||
name: Check for .codemodrc.json files changes | ||
runs-on: ubuntu-latest | ||
outputs: | ||
codemods: ${{ steps.filter.outputs.codemods }} | ||
codemods_files: ${{ steps.filter.outputs.codemods_files }} | ||
steps: | ||
- name: Harden the runner (Audit all outbound calls) | ||
uses: step-security/harden-runner@c6295a65d1254861815972266d5933fd6e532bdf | ||
with: | ||
egress-policy: audit | ||
|
||
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 | ||
- uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 | ||
id: filter | ||
name: Filter codemods | ||
with: | ||
list-files: json | ||
filters: | | ||
codemods: | ||
- '**/.codemodrc.json' | ||
|
||
prepare-matrix: | ||
name: Prepare matrix | ||
runs-on: ubuntu-latest | ||
needs: paths-filter | ||
if: always() && needs.paths-filter.outputs.codemods == 'true' | ||
outputs: | ||
codemod_files: ${{ steps.set-matrix.outputs.codemod_files }} | ||
steps: | ||
- name: Harden the runner (Audit all outbound calls) | ||
uses: step-security/harden-runner@c6295a65d1254861815972266d5933fd6e532bdf | ||
with: | ||
egress-policy: audit | ||
|
||
- name: Checkout Code | ||
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Set matrix for codemods | ||
id: set-matrix | ||
run: | | ||
FILES_JSON=$(echo '${{ needs.paths-filter.outputs.codemods_files }}' | jq -c '{include: map({file: .})}') | ||
echo "codemod_files=$FILES_JSON" >> "$GITHUB_OUTPUT" | ||
echo "Matrix JSON: $FILES_JSON" | ||
|
||
publish: | ||
name: Publish ${{ matrix.file }} | ||
runs-on: ubuntu-latest | ||
needs: prepare-matrix | ||
strategy: | ||
fail-fast: false | ||
matrix: ${{fromJson(needs.prepare-matrix.outputs.codemod_files)}} | ||
env: | ||
CODEMOD_API_KEY: ${{ secrets.CODEMOD_API_KEY }} | ||
steps: | ||
- name: Harden the runner (Audit all outbound calls) | ||
uses: step-security/harden-runner@c6295a65d1254861815972266d5933fd6e532bdf | ||
with: | ||
egress-policy: audit | ||
|
||
- name: Checkout Code | ||
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- uses: actions/setup-node@cdca7365b2dadb8aad0a33bc7601856ffabcc48e | ||
with: | ||
node-version-file: ".nvmrc" | ||
|
||
- name: Install dependencies | ||
AugustinMauroy marked this conversation as resolved.
Show resolved
Hide resolved
|
||
run: | | ||
sudo apt-get install libsecret-1-dev | ||
npm install -g codemod | ||
|
||
- name: Test codemod | ||
run: | | ||
DIR=$(dirname "${{ matrix.file }}") | ||
echo "Testing codemod in: $DIR" | ||
cd "$DIR" | ||
npm install | ||
npm run --if-present test | ||
|
||
- name: Publish codemod | ||
run: | | ||
DIR=$(dirname "${{ matrix.file }}") | ||
echo "Publishing codemod in: $DIR" | ||
cd "$DIR" | ||
npx codemod publish |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json