mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2026-01-04 06:24:07 +08:00
ci: run prettier write on pr label change
This commit is contained in:
parent
c469ddddff
commit
90590a331d
1 changed files with 40 additions and 35 deletions
75
.github/workflows/pretty-fix.yml
vendored
75
.github/workflows/pretty-fix.yml
vendored
|
|
@ -1,48 +1,53 @@
|
|||
name: Prettier Fix
|
||||
|
||||
env:
|
||||
PNPM_VERSION: "9.6.0"
|
||||
NODE_VERSION: "20.16.0"
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
reason:
|
||||
description: "Reason for manually triggering this workflow"
|
||||
required: false
|
||||
schedule:
|
||||
- cron: "0 0 * * 0"
|
||||
pull_request_target:
|
||||
types: [labeled]
|
||||
|
||||
jobs:
|
||||
prettier-fix:
|
||||
permissions: write-all
|
||||
prettify:
|
||||
runs-on: ubuntu-latest
|
||||
if: github.event.label.name == 'prettify'
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Set up date environment variables
|
||||
run: |
|
||||
echo "BRANCH_TITLE=pretty-fix-$(date +%s)" >> $GITHUB_ENV
|
||||
echo "PR_TITLE=Prettier Fix - $(date)" >> $GITHUB_ENV
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set up Node.js
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: "20.16.0"
|
||||
node-version: ${{ env.NODE_VERSION }}
|
||||
|
||||
- name: Install dependencies
|
||||
run: npm i prettier@2.5.1 --save-dev --save-exact
|
||||
|
||||
- name: Pretty Check
|
||||
run: npm run pretty-fix
|
||||
|
||||
- name: Create commits
|
||||
id: commits
|
||||
continue-on-error: true
|
||||
run: |
|
||||
git config user.name 'monkeytypegeorge'
|
||||
git config user.email 'monkeytypegeorge@gmail.com'
|
||||
git add .
|
||||
git commit -m 'refactor: run prettier'
|
||||
|
||||
- name: Create pull request
|
||||
uses: peter-evans/create-pull-request@v4
|
||||
- name: Setup pnpm
|
||||
uses: pnpm/action-setup@v4
|
||||
with:
|
||||
branch: ${{ env.BRANCH_TITLE }}
|
||||
title: ${{ env.PR_TITLE }}
|
||||
body: ${{ env.PR_TITLE }}
|
||||
version: ${{ env.PNPM_VERSION }}
|
||||
|
||||
- name: Install prettier
|
||||
run: pnpm add -g prettier@2.8.8
|
||||
|
||||
- name: Run Prettier fix
|
||||
run: pnpm prettier --write .
|
||||
|
||||
- name: Commit changes
|
||||
uses: stefanzweifel/git-auto-commit-action@v5
|
||||
with:
|
||||
commit_message: "prettier fix"
|
||||
|
||||
- name: Remove label
|
||||
uses: actions/github-script@v7
|
||||
with:
|
||||
script: |
|
||||
const { context, github } = require('@actions/github');
|
||||
await github.rest.issues.removeLabel({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
issue_number: context.issue.number,
|
||||
name: 'prettify'
|
||||
});
|
||||
Loading…
Add table
Reference in a new issue