-
Notifications
You must be signed in to change notification settings - Fork 0
106 lines (88 loc) · 2.92 KB
/
deploy.yml
File metadata and controls
106 lines (88 loc) · 2.92 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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
name: Deploy to GitHub Pages
on:
push:
branches: [main]
pull_request:
branches: [main]
workflow_dispatch:
permissions:
contents: read
pages: write
id-token: write
concurrency:
group: pages
cancel-in-progress: false
jobs:
check-changelog:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 2
- name: Check for CHANGELOG file in commit
run: |
# Get files changed in this push/PR
if [ "${{ github.event_name }}" = "pull_request" ]; then
FILES=$(git diff --name-only HEAD~1 HEAD 2>/dev/null || git diff --name-only ${{ github.event.pull_request.base.sha }} HEAD)
else
FILES=$(git diff --name-only HEAD~1 HEAD)
fi
echo "Changed files:"
echo "$FILES"
# Check if any code files changed (ignore docs-only)
CODE_FILES=$(echo "$FILES" | grep -vE '\.(md|txt|json)$' | grep -vE '^\.(agent|github)/' || true)
if [ -z "$CODE_FILES" ]; then
echo "✅ Docs-only commit — changelog not required."
exit 0
fi
# Reject changelogs placed in repo root instead of changelogs/
ROOT_CHANGELOG=$(echo "$FILES" | grep -E '^CHANGELOG-.*\.md$' || true)
if [ -n "$ROOT_CHANGELOG" ]; then
echo ""
echo "❌ FAILED: Changelog found in repo root — must be in changelogs/ directory."
echo " Found: $ROOT_CHANGELOG"
echo " Move it: git mv $ROOT_CHANGELOG changelogs/"
echo ""
exit 1
fi
# Check for CHANGELOG file in changelogs/ directory
CHANGELOG=$(echo "$FILES" | grep -E '^changelogs/CHANGELOG-.*\.md$' || true)
if [ -z "$CHANGELOG" ]; then
echo ""
echo "❌ FAILED: No changelog found in changelogs/ directory."
echo ""
echo "Every commit with code changes must include a changelogs/CHANGELOG-<topic>.md file."
echo "Example: changelogs/CHANGELOG-my-feature.md"
echo ""
exit 1
fi
echo "✅ Found changelog: $CHANGELOG"
build:
needs: check-changelog
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20
cache: npm
- name: Install dependencies
run: npm ci
- name: Build
run: npm run build
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: dist
deploy:
needs: build
runs-on: ubuntu-latest
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4