Repository navigation
171 lines (151 loc) · 6.13 KB
/
Copy pathupdate-plugins.yml
File metadata and controls
171 lines (151 loc) · 6.13 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
name: Update Plugins
on:
schedule:
- cron: '0 6 * * *' # Daily at 06:00 UTC
workflow_dispatch: # Allow manual trigger
inputs:
dry_run:
description: >-
Dry run: apply the fixes locally and print the diffs, but do not
commit, push or merge anything (runs without PLUGINS_PAT).
type: boolean
default: true
# The cross-repo work (cloning ether/ep_* repos, pushing updates, merging
# Dependabot PRs) is authenticated via secrets.PLUGINS_PAT. The default
# GITHUB_TOKEN only needs read access to this repo for actions/checkout.
permissions:
contents: read
env:
# Scheduled runs have no inputs, so they are never dry runs.
DRY_RUN: ${{ inputs.dry_run == true }}
# Repos the sweep never touches: ep_kaput is managed by hand, and the
# others use their own CI layout rather than the plugin templates.
SKIP_REPOS: ep_kaput ep_ai_chat ep_ai_core ep_ai_mcp ep_infos ep_plugin_helpers
jobs:
update-plugins:
runs-on: ubuntu-latest
steps:
- name: Check out etherpad
uses: actions/checkout@v7
- uses: pnpm/action-setup@v6.1.1
name: Install pnpm
with:
run_install: false
- name: Use Node.js
uses: actions/setup-node@v7
with:
node-version: '26'
- name: Install bin dependencies
working-directory: ./bin
run: pnpm install
- name: Configure git
run: |
git config --global user.name 'github-actions[bot]'
git config --global user.email '41898282+github-actions[bot]@users.noreply.github.com'
- name: Clone and update all plugins
env:
# Dry runs only read public repos, so they use the read-only
# GITHUB_TOKEN and cannot push anywhere.
GH_TOKEN: ${{ inputs.dry_run == true && github.token || secrets.PLUGINS_PAT }}
run: |
set -uo pipefail
if [ "$DRY_RUN" = true ]; then
mode=autofix
echo "Dry run: changes are applied locally and printed, nothing is pushed."
else
mode=autopush
# Use the PAT for all ether/ repos so checkPlugin can push.
git config --global url."https://x-access-token:${GH_TOKEN}@github.com/ether/".insteadOf "https://github.com/ether/"
fi
# checkPlugin expects each plugin checkout next to the core checkout.
core_dir="$GITHUB_WORKSPACE"
plugins_dir="$(dirname "$core_dir")"
plugins=$(gh repo list ether --limit 1000 --no-archived --json name \
--jq '.[] | select(.name | startswith("ep_")) | .name' | sort) || {
echo "::error::Could not list ether/ep_* repos"
exit 1
}
[ -n "$plugins" ] || { echo "::error::No ether/ep_* repos found"; exit 1; }
failed=()
succeeded=()
skipped=()
for plugin in $plugins; do
if [[ " $SKIP_REPOS " == *" $plugin "* ]]; then
skipped+=("$plugin")
continue
fi
echo "::group::$plugin"
plugin_dir="$plugins_dir/$plugin"
if [ ! -d "$plugin_dir" ] &&
! git clone "https://github.com/ether/${plugin}.git" "$plugin_dir"; then
echo "::error::$plugin: clone failed"
failed+=("$plugin (clone)")
elif ! git -C "$plugin_dir" pull --ff-only; then
echo "::error::$plugin: pull failed"
failed+=("$plugin (pull)")
elif ! (cd "$core_dir/bin" && pnpm run checkPlugin "$plugin" "$mode"); then
echo "::error::$plugin: checkPlugin failed"
failed+=("$plugin (checkPlugin)")
else
succeeded+=("$plugin")
fi
echo "::endgroup::"
done
{
if [ "$DRY_RUN" = true ]; then
echo "## Plugin template sync (dry run)"
else
echo "## Plugin template sync"
fi
echo ""
echo "- Succeeded: ${#succeeded[@]}"
echo "- Failed: ${#failed[@]}"
echo "- Skipped: ${#skipped[@]} (${skipped[*]:-none})"
if [ ${#failed[@]} -gt 0 ]; then
echo ""
echo "### Failed"
printf -- '- %s\n' "${failed[@]}"
fi
} | tee -a "$GITHUB_STEP_SUMMARY"
if [ ${#failed[@]} -gt 0 ]; then
echo "::error::${#failed[@]} plugin(s) failed: ${failed[*]}"
exit 1
fi
- name: Merge clean Dependabot PRs on plugin repos
# Run even when some plugins failed to sync; skip on dry runs.
if: ${{ !cancelled() && env.DRY_RUN != 'true' }}
env:
GH_TOKEN: ${{ secrets.PLUGINS_PAT }}
run: |
# For every ep_* repo under ether, merge any Dependabot PR whose
# mergeStateStatus is CLEAN (no conflicts, branch up to date, all
# required checks green). Anything else is left alone for a human.
plugins=$(gh repo list ether --limit 1000 --no-archived --json name --jq '.[] | select(.name | startswith("ep_")) | .name')
merged=""
merge_failed=""
for plugin in $plugins; do
# ep_kaput is managed by hand.
[ "$plugin" != ep_kaput ] || continue
repo="ether/${plugin}"
prs=$(gh pr list --repo "$repo" \
--author "app/dependabot" \
--state open \
--json number,mergeStateStatus,title \
--jq '.[] | select(.mergeStateStatus=="CLEAN") | .number') || continue
for pr in $prs; do
echo "Merging ${repo}#${pr}"
if gh pr merge --repo "$repo" --squash --delete-branch "$pr"; then
merged="$merged ${repo}#${pr}"
else
echo "::warning::failed to merge ${repo}#${pr}"
merge_failed="$merge_failed ${repo}#${pr}"
fi
done
done
{
echo ""
echo "## Dependabot merges"
echo ""
echo "- Merged:${merged:- none}"
echo "- Failed to merge:${merge_failed:- none}"
} | tee -a "$GITHUB_STEP_SUMMARY"