Prettier codes #946
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 codes | |
on: | |
workflow_run: | |
workflows: | |
- Test codes | |
types: | |
- completed | |
env: | |
workdir: client | |
node-version: lts/* | |
jobs: | |
front-filter: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: 'read' | |
pull-requests: 'read' | |
outputs: | |
client: ${{ steps.changes.outputs.client }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
ref: ${{ github.event.workflow_run.head_sha }} | |
- name: Check for file changes | |
uses: dorny/paths-filter@v2 | |
id: changes | |
with: | |
token: ${{ github.token }} | |
filters: .github/filters.yml | |
run-formatter: | |
runs-on: ubuntu-latest | |
needs: front-filter | |
if: needs.front-filter.outputs.client == 'true' && github.event.workflow_run.conclusion == 'success' | |
permissions: | |
contents: 'write' | |
defaults: | |
run: | |
working-directory: ${{ env.workdir }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
ref: ${{ github.event.workflow_run.head_sha }} | |
- name: Setup Node.js environment | |
uses: actions/setup-node@v3 | |
with: | |
node-version: ${{ env.node-version }} | |
- name: Install Dependencies | |
run: yarn install --immutable | |
- name: Format style codes | |
run: yarn run lint:style-fix | |
- name: Format the code | |
run: yarn run fmt | |
- name: Auto commit | |
run: | | |
git config --global user.name "${GITHUB_ACTOR}" | |
git config --global user.email "${GITHUB_ACTOR}@users.noreply.github.com" | |
if (git diff --shortstat | grep '[0-9]'); then \ | |
git add .; \ | |
git commit -m "fix(front): auto-fixable format by github-actions"; \ | |
git push origin HEAD:${GITHUB_REF}; \ | |
fi | |
run-formatter-check: | |
if: ${{ ! failure() }} | |
needs: run-formatter | |
runs-on: ubuntu-latest | |
steps: | |
- run: echo "Formatter is successfully executed. " |