-
Notifications
You must be signed in to change notification settings - Fork 7
151 lines (133 loc) · 5.02 KB
/
Copy pathci-cd.yml
File metadata and controls
151 lines (133 loc) · 5.02 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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
name: CI/CD Pipeline
on:
pull_request:
branches: [main]
push:
branches: [main]
jobs:
ci:
name: 🔄 Continuous Integration
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
with:
fetch-depth: 0
- name: Verify core/react version parity
run: |
CORE_VERSION=$(jq -r '.version' packages/core/package.json)
REACT_VERSION=$(jq -r '.version' packages/react/package.json)
if [ "$CORE_VERSION" != "$REACT_VERSION" ]; then
echo "::error::Version mismatch — core@$CORE_VERSION != react@$REACT_VERSION. Both packages must have the same version."
exit 1
fi
echo "Version parity OK: $CORE_VERSION"
- name: Setup pnpm
uses: pnpm/action-setup@36de12bed180fa130ed56a35e7344f2fa7a820ab # v4
with:
version: 10.6.5
- name: Setup Node.js
uses: actions/setup-node@0a44ba7841725637a19e28fa30b79a866c81b0a6 # v4.0.4
with:
node-version: "22"
cache: "pnpm"
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Check formatting
run: pnpm format:check
- name: Run linting
run: pnpm lint
- name: Type check
run: pnpm type-check
- name: Run tests
run: pnpm test
- name: Build packages
run: pnpm build
- name: Check registry.json is up to date
run: |
pnpm --filter @auth0/universal-components-react registry:generate
if ! git diff --exit-code packages/react/registry.json; then
echo "::error::registry.json is out of date. Run 'pnpm --filter @auth0/universal-components-react registry:generate' and commit the result."
exit 1
fi
- name: Validate shadcn registry
run: pnpm dlx shadcn@latest registry validate
notify:
name: Slack Notification
needs: [ci]
if: always()
runs-on:
labels: ubuntu-latest
steps:
- name: Send Slack notification
env:
SLACK_WEBHOOK: ${{ secrets.SLACK_CI_WORKFLOW_WEBHOOK }}
CI_RESULT: ${{ needs.ci.result }}
GITHUB_REPOSITORY: ${{ github.repository }}
GITHUB_BRANCH: ${{ github.head_ref || github.ref_name }}
GITHUB_ACTOR: ${{ github.actor }}
GITHUB_WORKFLOW: ${{ github.workflow }}
COMMIT_MESSAGE: ${{ github.event.head_commit.message }}
COMMIT_SHA: ${{ github.sha }}
GITHUB_SERVER_URL: ${{ github.server_url }}
GITHUB_RUN_ID: ${{ github.run_id }}
run: |
echo "Preparing Slack notification..."
# Determine overall status
if [[ "$CI_RESULT" == "success" ]]; then
STATUS="✅ SUCCESS: CI/CD Pipeline passed"
MESSAGE="All checks passed successfully"
else
STATUS="❌ FAILED: CI/CD Pipeline failed"
MESSAGE="One or more CI steps failed. Check the workflow run for details."
fi
# Output summary for GitHub logs
echo "=== WORKFLOW SUMMARY ==="
echo "Status: $STATUS"
echo "CI Result: $CI_RESULT"
echo ""
# Send notification to Slack (if webhook is configured)
if [ -n "$SLACK_WEBHOOK" ]; then
echo "Sending Slack notification..."
HTTP_CODE=$(curl -X POST "$SLACK_WEBHOOK" \
-H "Content-Type: application/json" \
-w "%{http_code}" \
-o /tmp/slack_response.txt \
-d "{
\"status\": \"$STATUS\",
\"message\": \"$MESSAGE\",
\"repository\": \"${GITHUB_REPOSITORY}\",
\"branch\": \"${GITHUB_BRANCH}\",
\"ci_result\": \"$CI_RESULT\",
\"actor\": \"${GITHUB_ACTOR}\",
\"workflow\": \"${GITHUB_WORKFLOW}\",
\"commit_message\": \"${COMMIT_MESSAGE}\",
\"commit_sha\": \"${COMMIT_SHA}\",
\"action_url\": \"${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}\"
}")
if [ "$HTTP_CODE" -ge 200 ] && [ "$HTTP_CODE" -lt 300 ]; then
echo "Slack notification sent successfully (HTTP $HTTP_CODE)"
else
echo "WARNING: Slack notification failed (HTTP $HTTP_CODE)"
cat /tmp/slack_response.txt
fi
else
echo "Slack webhook not configured, skipping notification"
fi
# CD job to be configured later
# cd:
# name: 📦 Continuous Deployment
# needs: [ci]
# if: github.event_name == 'push' && github.ref == 'refs/heads/main'
# runs-on: ubuntu-latest
# environment: production
# concurrency:
# group: production
# cancel-in-progress: false
# steps:
# - uses: actions/checkout@v4
# - uses: actions/setup-node@v4
# with:
# node-version: '22'
# cache: 'pnpm'
# - name: Deploy
# run: echo "Deployment steps will go here"