feat: add solutions to lcp problem: No.61 #2736
Workflow file for this run
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
name: prettier | |
on: | |
pull_request_target: | |
types: [opened, edited, reopened, synchronize] | |
concurrency: | |
group: ${{github.workflow}} - ${{github.ref}} | |
cancel-in-progress: true | |
jobs: | |
format: | |
permissions: | |
contents: write | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v4 | |
with: | |
repository: ${{ github.event.pull_request.head.repo.full_name }} | |
ref: ${{ github.head_ref }} | |
fetch-depth: 0 | |
- name: Set up Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 18 | |
- name: Install Dependencies | |
run: npm install | |
- name: Run prettier | |
run: | | |
git config --global core.quotepath off | |
changed_files=$(git diff --name-only "${{ github.event.pull_request.base.sha }}" | grep -E '\.js$|\.ts$|\.php$|\.sql$|\.rs$|\.md$' || true) | |
if [ -n "$changed_files" ]; then | |
echo "Running prettier on the changed files" | |
echo "$changed_files" | xargs -d '\n' npx prettier --write | |
else | |
echo "No matching files to run prettier on." | |
fi | |
- name: Commit changes | |
uses: stefanzweifel/git-auto-commit-action@v5 | |
with: | |
commit_message: "style: format code and docs with prettier" | |
commit_user_name: idoocs | |
commit_user_email: doocs-bot@outlook.com |