Skip to content

Commit

Permalink
Add new workflow and update
Browse files Browse the repository at this point in the history
  • Loading branch information
Gellipapa committed Jul 6, 2023
1 parent 03a0ddd commit c594312
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 8 deletions.
43 changes: 43 additions & 0 deletions .github/workflows/format-all.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: formatter-all

on:
push:
branches: [ main ]
pull_request:
types: [ labeled ]

jobs:
formatter:
name: formatter
runs-on: ubuntu-latest
permissions:
contents: write
if: ${{ github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.label.name == 'format_all') }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v3
with:
ref: ${{ github.head_ref }}
fetch-depth: 0
- uses: actions/setup-node@v3
with:
node-version: "16"
- name: Install stylua and format files
uses: JohnnyMorganz/stylua-action@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
version: v0.18.0
args: -- .
- name: Format files with Prettier
run: |
npx prettier --write '**/*.{ts,js,css,html}'
- name: Update repo before push
run: |
git pull
- name: Commit changes and push current branch
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_user_name: ESX GITHUB ACTIONS BOT
commit_user_email: [email protected]
commit_message: :art:Code formatted in all files
16 changes: 8 additions & 8 deletions .github/workflows/format-lua.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ jobs:
with:
ref: ${{ github.head_ref }}
fetch-depth: 0
- uses: actions/setup-node@v3
with:
node-version: "16"
- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@v37
Expand All @@ -34,14 +37,11 @@ jobs:
done
- name: Install stylua
if: steps.changed-files.outputs.any_changed == 'true'
run: |
wget https://github.com/JohnnyMorganz/StyLua/releases/download/v0.18.0/stylua-linux-x86_64.zip
unzip stylua-linux-x86_64.zip
chmod +x stylua
- name: Format changed files with StyLua
if: steps.changed-files.outputs.any_changed == 'true'
run: |
./stylua ${{ steps.changed-files.outputs.all_changed_files }}
uses: JohnnyMorganz/stylua-action@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
version: v0.18.0
args: -- ${{ steps.changed-files.outputs.all_changed_files }}
- name: Update repo before push
run: |
git pull
Expand Down

0 comments on commit c594312

Please sign in to comment.