-
Notifications
You must be signed in to change notification settings - Fork 47
80 lines (67 loc) · 2.14 KB
/
code-format.yml
File metadata and controls
80 lines (67 loc) · 2.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
name: 🎀 Code Format (Verification)
on:
push:
branches:
- main
- develop
pull_request:
jobs:
code-format:
runs-on: ubuntu-latest
defaults:
run:
shell: bash
environment: 'staging'
env:
DOPPLER_TOKEN: ${{ secrets.DOPPLER_TOKEN }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ github.head_ref || github.ref }}
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Install Doppler CLI
uses: dopplerhq/cli-action@v3
- name: Setup Doppler
run: |
doppler configure set token "$DOPPLER_TOKEN"
- name: Env vars health check
run: |
if ! doppler run -- printenv | grep -q 'NEXT_PUBLIC_SDK__AUTHENTICATION_URL'; then
echo "👹 Oops! Missing required environment variable during health check..."
exit 1
fi
echo "🚑 Doppler envVars seem healthy!"
- name: Setup dotenv
run: |
scripts/setup-ci-dotenv
- name: Install dependencies
run: npm ci
- name: Code format check
id: fmt_check
continue-on-error: true
run: |
if ! npm run fmt:check; then
echo "exit_code=1" >> "$GITHUB_OUTPUT"
fi
- name: Auto-format (Markdown files)
if: steps.fmt_check.outputs.exit_code != '0' && github.event_name == 'pull_request'
run: npx prettier --write "src/**/*.{md,mdx}"
- name: Commit formatted (Markdown files)
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 'action@github.com'
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