-
Notifications
You must be signed in to change notification settings - Fork 387
50 lines (48 loc) · 1.64 KB
/
pr-comment-generate-plots.yml
File metadata and controls
50 lines (48 loc) · 1.64 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
name: PR comment - Generate plots
on:
pull_request:
paths:
- '**/*.csv.gz'
jobs:
generate-plots:
name: Generate plots
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
with:
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: 0
- uses: astral-sh/setup-uv@v7
with:
working-directory: './utils/visualize'
- uses: actions/github-script@v9
name: List changed files from the PR
id: list-files
with:
script: |
const { execSync } = require('child_process')
const { commits } = context.payload.pull_request
const rawFiles = execSync(`git diff --name-only HEAD HEAD~${commits} | grep -E '(brightness|color_temp|hs|effect)\\.csv\\.gz$'`).toString()
const files = rawFiles.split('\n').filter(Boolean)
core.setOutput('changedFiles', "\"" + files.join("\" \"") + "\"")
- name: Run visualization tool
run: |
cd ./utils/visualize
for file in ${{ steps.list-files.outputs.changedFiles }}; do
echo "Generating plot for - ${file}."
if [ -f "${{ github.workspace }}/${file}" ]; then
uv run python plot.py "${{ github.workspace }}/${file}" --output=auto
fi
done
- name: Save PR number
env:
PR_NUMBER: ${{ github.event.number }}
run: |
echo $PR_NUMBER > pr_number.txt
- name: Upload Artifact
uses: actions/upload-artifact@v7
with:
name: plots
path: |
./pr_number.txt
./utils/visualize/*.png