add format workflow
This commit is contained in:
46
.github/workflows/format.yml
vendored
Normal file
46
.github/workflows/format.yml
vendored
Normal file
@@ -0,0 +1,46 @@
|
||||
name: Format
|
||||
on:
|
||||
push:
|
||||
paths:
|
||||
- 'lua/**.lua'
|
||||
- '**.md'
|
||||
- '.github/**.yml'
|
||||
branches: [main, dev]
|
||||
|
||||
jobs:
|
||||
format:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: write
|
||||
pull-requests: write
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
STYLUA_VERSION: 0.11.0
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- name: Setup git
|
||||
run: |
|
||||
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
|
||||
git config --local user.name "github-actions[bot]"
|
||||
printf 'STYLE_BRANCH=bot/style/%s\n' ${GITHUB_REF#refs/heads/} >> $GITHUB_ENV
|
||||
|
||||
- name: Apply stylua
|
||||
run: |
|
||||
git checkout -b ${STYLE_BRANCH}
|
||||
curl -Lo /tmp/stylua.zip https://github.com/JohnnyMorganz/StyLua/releases/download/v${STYLUA_VERSION}/stylua-${STYLUA_VERSION}-linux.zip
|
||||
unzip -d /tmp/ /tmp/stylua.zip
|
||||
chmod +x /tmp/stylua
|
||||
/tmp/stylua --config-path=.stylua.toml lua/
|
||||
|
||||
- name: Apply prettier
|
||||
uses: creyD/prettier_action@v4.0
|
||||
|
||||
- name: Create PR
|
||||
run: |
|
||||
if ! [[ -z $(git status -s) ]]; then
|
||||
git add -u
|
||||
git commit -m "chore: format"
|
||||
git push --force https://${GITHUB_ACTOR}:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY} ${STYLE_BRANCH}
|
||||
gh pr create --fill --base ${GITHUB_REF#refs/heads/} --head ${STYLE_BRANCH} || true
|
||||
fi
|
||||
Reference in New Issue
Block a user