Skip to content

Commit

Permalink
chore: 🤖 Provide CI/CD code formatting (#11)
Browse files Browse the repository at this point in the history
## Why?

Provide CI/CD code formatting

## How?

- Created a GitHub action
- Runs the format:unsafe script for verification

## Tickets?

-
[PLAT-1131](https://linear.app/fleekxyz/issue/PLAT-1131/provide-cicd-code-formatting-for-fleek-platformcli)

## Contribution checklist?

- [x] The commit messages are detailed
- [x] The `build` command runs locally
- [ ] Assets or static content are linked and stored in the project
- [x] You have manually tested
- [ ] You have provided tests

## Security checklist?

- [ ] Sensitive data has been identified and is being protected properly
- [ ] Injection has been prevented (parameterized queries, no eval or
system calls)

## Preview?

Optionally, provide the preview url here

---------

Co-authored-by: GitHub Action <[email protected]>
  • Loading branch information
heldrida and actions-user authored Jul 11, 2024
1 parent 3dc4520 commit f75ea2e
Show file tree
Hide file tree
Showing 2 changed files with 1,146 additions and 1,270 deletions.
74 changes: 74 additions & 0 deletions .github/workflows/code-format.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
name: 🎀 Code Format (Verification)

on:
push:
branches:
- main
- develop
pull_request:

jobs:
code-format:
runs-on: ubuntu-latest
defaults:
run:
shell: bash
steps:
- uses: actions/create-github-app-token@v1
id: fleek-platform-bot-token
with:
app-id: ${{ secrets.FLEEK_PLATFORM_BOT_APP_ID }}
private-key: ${{ secrets.FLEEK_PLATFORM_BOT_PRIVATE_KEY }}

- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ github.head_ref || github.ref }}
token: ${{ steps.fleek-platform-bot-token.outputs.token }}

- uses: pnpm/action-setup@v4
name: Install pnpm
with:
version: 7
run_install: false

- name: Setup Nodejs
uses: actions/setup-node@v4
with:
node-version: 20
cache: 'pnpm'

- name: Install dependencies
run: |
pnpm install \
--strict-peer-dependencies
- name: Code format check
id: fmt_check
continue-on-error: true
run: |
if ! pnpm format:check; then
echo "exit_code=1" >> "$GITHUB_OUTPUT"
fi
- name: Auto-format
if: steps.fmt_check.outputs.exit_code != '0' && github.event_name == 'pull_request'
run: |
pnpm format:unsafe
- name: Commit formatted
if: steps.fmt_check.outputs.exit_code != '0' && github.event_name == 'pull_request'
run: |
git config --global user.name 'GitHub Action'
git config --global user.email '[email protected]'
if [[ -n "$(git status --porcelain)" ]]; then
git add .
if git commit -m "chore: 🤖 code format" --no-verify; then
git push
else
echo "🦖 Skipped! No changes to commit..."
fi
else
echo "🦖 Skipped! No changes found."
fi
Loading

0 comments on commit f75ea2e

Please sign in to comment.