Skip to content

Commit f9aa3c9

Browse files
authored
ci(primitives): run less often, run on pull requests (#357)
- Run every 2 weeks (roughly) instead of 3x/week. - Run on pull requests also, so that changes to the workflow file and its dependencies are "tested" prior to merging. This does not run tests against the generated primitives however.
1 parent b17b727 commit f9aa3c9

File tree

1 file changed

+47
-14
lines changed

1 file changed

+47
-14
lines changed

.github/workflows/update-color-primitives.yml

+47-14
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,30 @@
11
name: Get/Update Primer Color Primitives
22

33
env:
4-
_DEST_DIR: "${{ github.workspace }}/lua/github-theme/palette/primitives"
5-
_JSON_DIR: "${{ github.workspace }}/node_modules/@primer/primitives/dist/json/colors"
6-
_LICENSE_GLOB: "${{ github.workspace }}/node_modules/@primer/primitives/[Ll][Ii][Cc][Ee][Nn][Ss][Ee]*"
7-
_PRIMITIVES_PKGJSON: "${{ github.workspace }}/node_modules/@primer/primitives/package.json"
4+
_DEST_DIR: '${{ github.workspace }}/lua/github-theme/palette/primitives'
5+
_JSON_DIR: '${{ github.workspace }}/node_modules/@primer/primitives/dist/json/colors'
6+
_LICENSE_GLOB: '${{ github.workspace }}/node_modules/@primer/primitives/[Ll][Ii][Cc][Ee][Nn][Ss][Ee]*'
7+
_PRIMITIVES_PKGJSON: '${{ github.workspace }}/node_modules/@primer/primitives/package.json'
88

99
on:
1010
workflow_dispatch:
1111
schedule:
12-
# 3x per week (every other day) at 12:40pm Pacific Time
13-
- cron: "40 19 * * 1,3,5"
12+
- cron: '40 19 */14 * *' # Roughly every 14 days (at 12:40pm Pacific Time)
13+
push:
14+
branches:
15+
- '**' # Any branch, but ignore tag pushes
16+
paths:
17+
- .github/workflows/**/*
18+
- scripts/**/*
19+
pull_request:
20+
paths:
21+
- .github/workflows/**/*
22+
- scripts/**/*
1423

1524
jobs:
1625
get-colors:
1726
runs-on: ubuntu-latest
18-
permissions:
27+
permissions: # NOTE: `write` is not applied for PR's from forks
1928
checks: write
2029
contents: write
2130
issues: write
@@ -28,12 +37,13 @@ jobs:
2837

2938
- uses: actions/setup-node@v4
3039
with:
31-
node-version: "lts/*"
40+
node-version: lts/*
3241
check-latest: true
3342

3443
- run: npm i @primer/primitives@latest
3544

36-
- run: |
45+
- name: Generate Lua files
46+
run: |
3747
set -u +f
3848
shopt -s nocaseglob failglob
3949
license="$(<$_LICENSE_GLOB)"
@@ -56,15 +66,38 @@ jobs:
5666
EOF
5767
done
5868
59-
- uses: JohnnyMorganz/stylua-action@v4
69+
- name: Check formatting (stylua)
70+
uses: JohnnyMorganz/stylua-action@v4
6071
with:
6172
token: ${{ secrets.GITHUB_TOKEN }}
6273
version: latest
6374
args: -f stylua.toml --verify -- ${{ env._DEST_DIR }}
6475

65-
- uses: peter-evans/create-pull-request@v6
76+
- id: diff
77+
run: git diff --quiet -- "$_DEST_DIR" || echo has_diff=true >> "$GITHUB_OUTPUT"
78+
79+
- if: ${{ steps.diff.outputs.has_diff }}
80+
uses: actions/upload-artifact@v4
81+
with:
82+
name: primitives
83+
path: ${{ env._DEST_DIR }}
84+
retention-days: ${{ (github.event_name != 'push' || github.ref_name != 'main') && 14 || null }}
85+
if-no-files-found: error
86+
overwrite: true
87+
88+
- if: ${{ github.event_name == 'push' || github.event_name == 'schedule' }}
89+
uses: peter-evans/create-pull-request@v6
6690
with:
67-
commit-message: Update color primitives
68-
branch: update-color-primitives
6991
delete-branch: true
70-
title: Update color primitives
92+
branch: generated/primitives/${{ github.ref_name }}
93+
commit-message: 'deps: update color primitives'
94+
title: 'deps: update color primitives'
95+
body: |
96+
| | |
97+
| ----------------- | ------------------------ |
98+
| **Trigger** | ${{ github.event_name }} |
99+
| **Target Branch** | ${{ github.ref_name }} |
100+
101+
> [!NOTE]
102+
> Checks are not automatically run for this PR.
103+
> Close and reopen this PR to run tests and checks (against the newly generated primitives).

0 commit comments

Comments
 (0)