-
Notifications
You must be signed in to change notification settings - Fork 566
58 lines (58 loc) · 2.43 KB
/
analyze-builds.yml
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
name: ESM Sample Metrics
on:
pull_request:
types: [opened, reopened, synchronize, labeled, unlabeled]
branches: [main]
jobs:
analyze:
if: "!contains(github.event.pull_request.labels.*.name, 'draft') && github.actor!='dependabot-preview[bot]'"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.ref }}
token: ${{ secrets.ESM_BUILD }}
- name: should samples build
id: build
run: |
current_branch=$(git rev-parse --abbrev-ref HEAD)
# package.json files changed in the branch
packages_changed=$(git diff --name-only "$current_branch" $(git merge-base "$current_branch" origin/main) -- "./esm-samples/**/package.json")
# metric files changed in the previous commit
metrics_changed=$(git diff --name-only HEAD^ HEAD -- "./esm-samples/.metrics/*.csv")
if [ -z "$packages_changed" ]; then
echo "no package.json files changed, skipping build analysis"
elif [ -n "$metrics_changed" ]; then
echo "metric files changed: $metrics_changed"
echo "the previous commit contained build metrics, skipping build analysis"
else
echo "package.json files changed: $packages_changed"
echo "analyzing builds"
echo "skip=false" >> $GITHUB_OUTPUT
fi
- if: steps.build.outputs.skip == 'false'
name: setup node
uses: actions/setup-node@v3
with:
node-version: 16
- if: steps.build.outputs.skip == 'false'
name: install dependencies for sample metrics script
run: |
cd ./.github/scripts/
npm i
- if: steps.build.outputs.skip == 'false'
name: run sample metrics script
run: node ./.github/scripts/analyze-builds.js
- name: push sample metrics analysis
if: steps.build.outputs.skip == 'false'
run: |
git branch
git status
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git add ./esm-samples/.metrics/*.csv
git status
git commit -m "ci: analyze esm sample builds" || true
git push origin ${{ github.event.pull_request.head.ref }}
git status