Repository navigation
182 lines (165 loc) · 7.74 KB
/
Copy pathsyncweaver-host-update.yml
File metadata and controls
182 lines (165 loc) · 7.74 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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
name: syncweaver-host-update
on:
repository_dispatch:
workflow_dispatch:
inputs:
source_path:
description: Optional tracked source path override for manual runs; if omitted, source_path is resolved from the lockfile.
required: false
type: string
repo_url:
description: Optional source repository identifier (URL or OWNER/REPO) used to resolve source_path from lockfile; for repository_dispatch this defaults to client_payload.source_repository.
required: false
type: string
lockfile:
description: Path to the syncweaver lockfile.
required: false
default: .syncweaver-lock.json
type: string
ref:
description: Optional git ref to sync from.
required: false
type: string
remote_subdir:
description: Optional remote subdirectory to vendor.
required: false
type: string
syncweaver_version:
description: syncweaver version/ref for setup fallback (e.g. main, v0.1.0, or commit SHA).
required: false
type: string
default: main
syncweaver_image:
description: Optional explicit Docker image override for syncweaver commands.
required: false
type: string
permissions:
contents: write
pull-requests: write
jobs:
resolve-source-paths:
runs-on: ubuntu-latest
outputs:
source_paths: ${{ steps.resolve_source_paths.outputs.source_paths }}
source_count: ${{ steps.resolve_source_paths.outputs.source_count }}
lockfile: ${{ env.LOCKFILE }}
ref: ${{ env.REF }}
remote_subdir: ${{ env.REMOTE_SUBDIR }}
repo_url: ${{ env.REPO_URL }}
syncweaver_version: ${{ steps.job_meta.outputs.syncweaver_version }}
syncweaver_image: ${{ steps.job_meta.outputs.syncweaver_image }}
env:
# workflow_dispatch may provide source_path directly; repository_dispatch usually
# omits it so the workflow resolves source_path from lockfile + source_repository.
SOURCE_PATH: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.source_path || github.event.client_payload.source_path || '' }}
# Prefer explicit repo_url, then fall back to source_repository from dispatch payload.
REPO_URL: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.repo_url || github.event.client_payload.repo_url || github.event.client_payload.source_repository || '' }}
LOCKFILE: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.lockfile || github.event.client_payload.lockfile || '.syncweaver-lock.json' }}
REF: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.ref || github.event.client_payload.ref || '' }}
REMOTE_SUBDIR: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.remote_subdir || github.event.client_payload.remote_subdir || '' }}
SYNCWEAVER_VERSION: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.syncweaver_version || github.event.client_payload.syncweaver-version || 'main' }}
SYNCWEAVER_IMAGE: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.syncweaver_image || github.event.client_payload.syncweaver-image || '' }}
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Setup syncweaver
uses: CCBR/syncweaver/actions/setup-syncweaver@main
with:
syncweaver-version: ${{ env.SYNCWEAVER_VERSION }}
syncweaver-image: ${{ env.SYNCWEAVER_IMAGE }}
- name: Capture syncweaver inputs
id: job_meta
shell: bash
run: |
set -euo pipefail
echo "syncweaver_version=${SYNCWEAVER_VERSION}" >> "$GITHUB_OUTPUT"
echo "syncweaver_image=${SYNCWEAVER_IMAGE}" >> "$GITHUB_OUTPUT"
- name: Resolve source paths
id: resolve_source_paths
shell: bash
env:
SOURCE_PATH_INPUT: ${{ env.SOURCE_PATH }}
REPO_URL_INPUT: ${{ env.REPO_URL }}
LOCKFILE_PATH: ${{ env.LOCKFILE }}
run: |
set -euo pipefail
python - <<'PY' >> "$GITHUB_OUTPUT"
import json
import os
import pathlib
from syncweaver.lockfile import resolve_source_paths_from_lockfile
source_path_input = os.environ["SOURCE_PATH_INPUT"].strip()
repo_url_input = os.environ["REPO_URL_INPUT"].strip()
lockfile_path = pathlib.Path(os.environ["LOCKFILE_PATH"])
try:
resolved_source_paths = resolve_source_paths_from_lockfile(
lockfile=lockfile_path,
source_path=source_path_input,
repo_url=repo_url_input,
)
except ValueError as exc:
raise SystemExit(f"Error: {exc}") from exc
print(f"source_paths={json.dumps(resolved_source_paths)}")
print(f"source_count={len(resolved_source_paths)}")
PY
- name: Print resolved source paths
shell: bash
run: |
set -euo pipefail
echo "source_count=${{ steps.resolve_source_paths.outputs.source_count }}"
echo "source_paths=${{ steps.resolve_source_paths.outputs.source_paths }}"
update-source:
runs-on: ubuntu-latest
needs: resolve-source-paths
strategy:
fail-fast: false
matrix:
source_path: ${{ fromJson(needs.resolve-source-paths.outputs.source_paths) }}
env:
LOCKFILE: ${{ needs.resolve-source-paths.outputs.lockfile }}
REF: ${{ needs.resolve-source-paths.outputs.ref }}
REMOTE_SUBDIR: ${{ needs.resolve-source-paths.outputs.remote_subdir }}
REPO_URL: ${{ needs.resolve-source-paths.outputs.repo_url }}
SYNCWEAVER_VERSION: ${{ needs.resolve-source-paths.outputs.syncweaver_version }}
SYNCWEAVER_IMAGE: ${{ needs.resolve-source-paths.outputs.syncweaver_image }}
steps:
- name: Generate CCBR-bot token
id: ccbr_bot
uses: actions/create-github-app-token@v1
with:
app-id: ${{ vars.CCBR_BOT_APP_ID }}
private-key: ${{ secrets.CCBR_BOT_PRIVATE_KEY }}
- name: Checkout repository
uses: actions/checkout@v6
with:
token: ${{ steps.ccbr_bot.outputs.token }}
- name: Run update-source composite action
id: update_source
uses: CCBR/syncweaver/actions/update-source@latest
with:
source_path: ${{ matrix.source_path }}
lockfile: ${{ env.LOCKFILE }}
ref: ${{ env.REF }}
remote_subdir: ${{ env.REMOTE_SUBDIR }}
syncweaver-version: ${{ env.SYNCWEAVER_VERSION }}
syncweaver-image: ${{ env.SYNCWEAVER_IMAGE }}
- name: Commit changes and open PR
uses: peter-evans/create-pull-request@v7
with:
token: ${{ steps.ccbr_bot.outputs.token }}
branch: syncweaver/update-source/${{ matrix.source_path }}
delete-branch: true
commit-message: "chore(syncweaver): update ${{ matrix.source_path }} from ${{ steps.update_source.outputs.source_repo }}@${{ steps.update_source.outputs.ref }}"
title: "chore(syncweaver): update ${{ matrix.source_path }} from ${{ steps.update_source.outputs.source_repo }}@${{ steps.update_source.outputs.ref }}"
body: |
Automated source update from the update-source workflow.
Inputs used:
- source_path: ${{ matrix.source_path }}
- repo_url: ${{ env.REPO_URL }}
- lockfile: ${{ env.LOCKFILE }}
- ref: ${{ env.REF }}
- remote_subdir: ${{ env.REMOTE_SUBDIR }}
Resolved from lockfile after update:
- source_url: ${{ steps.update_source.outputs.source_url }}
- ref: ${{ steps.update_source.outputs.ref }}
- remote_subdir: ${{ steps.update_source.outputs.remote_subdir }}