forked from
quillmatiq.com/augment
Fork of Chiri for Astro for my blog
1name: CI
2
3on:
4 push:
5 branches: [main, master]
6 pull_request:
7 branches: [main, master]
8 check_suite:
9 types: [completed]
10 status: {}
11
12concurrency:
13 group: ${{ github.workflow }}-${{ github.ref }}
14 cancel-in-progress: true
15
16permissions:
17 contents: write
18 pull-requests: write
19 checks: read
20
21jobs:
22 validate:
23 name: Validate Code & Build
24 runs-on: ubuntu-latest
25
26 steps:
27 - name: Checkout code
28 uses: actions/checkout@v6
29
30 - name: Setup pnpm
31 uses: pnpm/action-setup@v4
32 with:
33 version: latest
34
35 - name: Setup Node.js
36 uses: actions/setup-node@v6
37 with:
38 node-version: 'latest'
39 cache: 'pnpm'
40
41 - name: Install dependencies
42 run: pnpm install --frozen-lockfile --prefer-offline
43
44 - name: Check formatting (if prettier is available)
45 run: |
46 if [ -f "pnpm-lock.yaml" ] && pnpm list prettier &>/dev/null; then
47 pnpm exec prettier --check .
48 else
49 echo "Prettier not configured, skipping format check"
50 fi
51 continue-on-error: true
52
53 - name: Run ESLint (if available)
54 run: |
55 if [ -f "pnpm-lock.yaml" ] && pnpm list eslint &>/dev/null; then
56 pnpm exec eslint .
57 else
58 echo "ESLint not configured, skipping lint check"
59 fi
60 continue-on-error: true
61
62 - name: Run linting
63 run: pnpm lint
64
65 - name: Build project
66 run: pnpm build
67
68 auto-merge:
69 name: Auto Merge
70 runs-on: ubuntu-latest
71 needs: validate
72 if: >
73 github.event_name == 'pull_request' &&
74 github.event.pull_request.draft == false &&
75 (
76 github.actor == 'dependabot[bot]' ||
77 contains(github.event.pull_request.labels.*.name, 'automerge')
78 )
79
80 steps:
81 - name: Checkout code
82 uses: actions/checkout@v6
83 with:
84 token: ${{ secrets.GITHUB_TOKEN }}
85
86 - name: Auto approve Dependabot PRs
87 if: github.actor == 'dependabot[bot]'
88 uses: hmarr/auto-approve-action@v4
89 with:
90 github-token: ${{ secrets.GITHUB_TOKEN }}
91 pull-request-number: ${{ github.event.pull_request.number }}
92
93 - name: Wait for all checks to complete
94 uses: fountainhead/action-wait-for-check@v1.2.0
95 id: wait-for-checks
96 with:
97 token: ${{ secrets.GITHUB_TOKEN }}
98 checkName: 'Validate Code & Build'
99 ref: ${{ github.event.pull_request.head.sha || github.sha }}
100 timeoutSeconds: 600
101 intervalSeconds: 10
102
103 - name: Auto merge
104 if: steps.wait-for-checks.outputs.conclusion == 'success'
105 uses: actions/github-script@v8
106 with:
107 github-token: ${{ secrets.GITHUB_TOKEN }}
108 script: |
109 const { data: pullRequest } = await github.rest.pulls.get({
110 owner: context.repo.owner,
111 repo: context.repo.repo,
112 pull_number: context.issue.number
113 });
114
115 await github.rest.pulls.merge({
116 owner: context.repo.owner,
117 repo: context.repo.repo,
118 pull_number: context.issue.number,
119 merge_method: 'squash',
120 commit_title: pullRequest.title,
121 commit_message: pullRequest.body || ''
122 });