-
Notifications
You must be signed in to change notification settings - Fork 5
67 lines (60 loc) · 2.62 KB
/
Copy pathsync-from-monorepo.yml
File metadata and controls
67 lines (60 loc) · 2.62 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
name: Sync skills from monorepo
on:
schedule:
- cron: "37 6 * * 1"
workflow_dispatch:
permissions:
contents: write
pull-requests: write
jobs:
sync:
runs-on: ubuntu-latest
if: github.repository == 'triggerdotdev/skills'
steps:
- uses: actions/checkout@v4
- name: Fetch monorepo skills
run: |
git clone --depth 1 --filter=blob:none --no-checkout \
https://github.com/triggerdotdev/trigger.dev.git monorepo
git -C monorepo sparse-checkout set --no-cone packages/cli-v3/skills
git -C monorepo checkout
echo "MONOREPO_SHA=$(git -C monorepo rev-parse HEAD)" >> "$GITHUB_ENV"
- name: Apply sync map
run: |
set -euo pipefail
SRC=monorepo/packages/cli-v3/skills
jq -r 'to_entries[] | "\(.key)\t\(.value)"' sync-map.json |
while IFS=$'\t' read -r src dst; do
[ -d "$SRC/$src" ] || { echo "::warning::mapped skill '$src' not found in monorepo"; continue; }
rm -rf "./$dst"
cp -R "$SRC/$src" "./$dst"
done
comm -23 \
<(find "$SRC" -mindepth 1 -maxdepth 1 -type d -printf '%f\n' | sort) \
<(jq -r 'keys[]' sync-map.json | sort) \
| sed 's/^/::warning::unmapped monorepo skill: /'
rm -rf monorepo
- name: Open or update pull request
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
set -euo pipefail
if [ -z "$(git status --porcelain)" ]; then
echo "No changes to sync."
exit 0
fi
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git checkout -B sync/monorepo-skills
git add -A
git commit -m "chore: sync skills from triggerdotdev/trigger.dev@${MONOREPO_SHA:0:7}"
git push --force-with-lease origin sync/monorepo-skills
body="Automated weekly sync from [\`triggerdotdev/trigger.dev@${MONOREPO_SHA:0:7}\`](https://github.com/triggerdotdev/trigger.dev/commit/${MONOREPO_SHA}).
Mappings live in \`sync-map.json\`. To publish a new monorepo skill, add an entry there. See the workflow run for any unmapped skills."
existing=$(gh pr list --head sync/monorepo-skills --state open --json number --jq '.[0].number // empty')
if [ -n "$existing" ]; then
gh pr edit "$existing" --body "$body"
else
gh pr create --head sync/monorepo-skills --base main \
--title "chore: sync skills from monorepo" --body "$body"
fi