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