-
Notifications
You must be signed in to change notification settings - Fork 1
105 lines (90 loc) · 3.95 KB
/
weekly-metrics.yml
File metadata and controls
105 lines (90 loc) · 3.95 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
name: Weekly Design System Metrics
on:
schedule:
# Friday 16:00 UTC. GitHub.com supports `timezone:` on schedules; this org's runners reject it ("not yet supported"),
# so we use UTC only. 16:00 UTC ≈ 8:00 AM PST / 9:00 AM PDT (America/Los_Angeles).
- cron: '0 16 * * 5'
workflow_dispatch: # Allow manual trigger
permissions:
contents: write
pull-requests: write
jobs:
generate-metrics:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Enable Corepack
run: corepack enable
- name: Install dependencies
run: yarn install --immutable
- name: Initialize git submodules
run: |
git config --global user.email 'metamaskbot@users.noreply.github.com'
git config --global user.name 'metamaskbot'
git submodule update --init --recursive || true
- name: Update git submodules
run: |
cd repos/metamask-extension && git fetch origin && git checkout main && git pull origin main && cd ../..
cd repos/metamask-mobile && git fetch origin && git checkout main && git pull origin main && cd ../..
cd repos/metamask-design-system && git fetch origin && git checkout main && git pull origin main && cd ../..
git add repos/
- name: Get current date
id: date
run: echo "date=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT
- name: Run pipeline
run: yarn pipeline
- name: Copy untracked latest for dashboard
run: |
cp metrics/extension-untracked-${{ steps.date.outputs.date }}.json metrics/extension-untracked-latest.json
cp metrics/mobile-untracked-${{ steps.date.outputs.date }}.json metrics/mobile-untracked-latest.json
cp metrics/extension-untracked-${{ steps.date.outputs.date }}.json dashboard/public/metrics/extension-untracked-latest.json
cp metrics/mobile-untracked-${{ steps.date.outputs.date }}.json dashboard/public/metrics/mobile-untracked-latest.json
- name: Install dashboard dependencies
run: |
cd dashboard
npm ci
- name: Build dashboard
run: |
cd dashboard
npm run build
- name: Commit, push branch, open pull request
env:
GH_TOKEN: ${{ github.token }}
run: |
set -e
git config --global user.email 'metamaskbot@users.noreply.github.com'
git config --global user.name 'metamaskbot'
git add .
if git diff --staged --quiet; then
echo "No changes to commit"
exit 0
fi
BRANCH="metamaskbot/weekly-metrics-${{ steps.date.outputs.date }}-${{ github.run_id }}"
git checkout -b "$BRANCH"
git commit -m "chore: weekly metrics update ${{ steps.date.outputs.date }}" \
-m "- Updated git submodules to latest versions" \
-m "- Regenerated component metrics for extension and mobile" \
-m "- Updated config.json with latest component mappings" \
-m "- Updated dashboard data and rebuilt" \
-m "" \
-m "🤖 Automated weekly update"
git push -u origin "$BRANCH"
BODY_FILE="$(mktemp)"
{
echo "Automated weekly metrics run."
echo ""
echo "- [ ] Review generated artifacts and merge to publish the dashboard (merge to **main** triggers GitHub Pages deploy)."
echo ""
echo "🤖 Workflow: https://github.com/${{ github.repository }}/blob/main/.github/workflows/weekly-metrics.yml"
} > "$BODY_FILE"
gh pr create --base main --head "$BRANCH" \
--title "chore: weekly metrics update ${{ steps.date.outputs.date }}" \
--body-file "$BODY_FILE"
rm -f "$BODY_FILE"