Skip to content

Commit 8025bfd

Browse files
committed
Use the io.github.kastro5 namespace for Ulanzi D200X / D200H; merge upstream main
2 parents 58dc7c4 + e28f7a5 commit 8025bfd

24 files changed

Lines changed: 325 additions & 11 deletions
Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
name: Format PR icons
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
pr_number:
7+
description: Pull request number to format
8+
required: true
9+
type: number
10+
11+
permissions:
12+
contents: write
13+
issues: read
14+
pull-requests: read
15+
16+
jobs:
17+
format:
18+
name: Format added icons
19+
runs-on: ubuntu-latest
20+
env:
21+
PR_NUMBER: ${{ inputs.pr_number }}
22+
GH_TOKEN: ${{ github.token }}
23+
steps:
24+
- name: Check out trusted formatter
25+
uses: actions/checkout@v7
26+
with:
27+
path: base
28+
ref: ${{ github.event.repository.default_branch }}
29+
fetch-depth: 1
30+
31+
- name: Get pull request head
32+
id: pr
33+
run: |
34+
gh pr view "$PR_NUMBER" --repo "${{ github.repository }}" --json \
35+
headRefName,headRepository,headRefOid,maintainerCanModify \
36+
--jq '"head_ref=\(.headRefName)\nhead_repository=\(.headRepository.nameWithOwner)\nhead_sha=\(.headRefOid)\nmaintainer_can_modify=\(.maintainerCanModify)"' >> "$GITHUB_OUTPUT"
37+
38+
- name: Require maintainer edits
39+
if: >-
40+
steps.pr.outputs.head_repository != github.repository &&
41+
steps.pr.outputs.maintainer_can_modify != 'true'
42+
run: |
43+
echo "This PR does not allow edits from maintainers." >&2
44+
exit 1
45+
46+
- name: Check out pull request
47+
uses: actions/checkout@v7
48+
with:
49+
repository: ${{ steps.pr.outputs.head_repository }}
50+
ref: ${{ steps.pr.outputs.head_sha }}
51+
path: pr
52+
token: ${{ github.token }}
53+
54+
- name: Set up uv
55+
uses: astral-sh/setup-uv@v7
56+
with:
57+
enable-cache: true
58+
59+
- name: Set up Python
60+
uses: actions/setup-python@v7
61+
with:
62+
python-version: "3.13"
63+
64+
- name: Format added icons
65+
id: format
66+
run: |
67+
set -euo pipefail
68+
mkdir -p format/icons
69+
70+
mapfile -t added_icons < <(
71+
gh api --paginate "repos/${{ github.repository }}/pulls/$PR_NUMBER/files" \
72+
--jq '.[] | select(.status == "added" and (.filename | startswith("icons/"))) | .filename'
73+
)
74+
75+
if ((${#added_icons[@]} == 0)); then
76+
echo "No added icons found in PR #$PR_NUMBER."
77+
echo "changed=false" >> "$GITHUB_OUTPUT"
78+
exit 0
79+
fi
80+
81+
for path in "${added_icons[@]}"; do
82+
relative_path="${path#icons/}"
83+
if [[ "$relative_path" == */* ]]; then
84+
echo "Icon path must be directly under icons/: $path" >&2
85+
exit 1
86+
fi
87+
cp "pr/$path" "format/icons/$relative_path"
88+
done
89+
90+
(
91+
cd format
92+
uv run --project ../base --locked python ../base/format_icons.py
93+
)
94+
95+
changed=false
96+
for path in "${added_icons[@]}"; do
97+
relative_path="${path#icons/}"
98+
if ! cmp -s "format/icons/$relative_path" "pr/$path"; then
99+
cp "format/icons/$relative_path" "pr/$path"
100+
changed=true
101+
fi
102+
done
103+
echo "changed=$changed" >> "$GITHUB_OUTPUT"
104+
105+
- name: Commit formatted icons to pull request
106+
if: steps.format.outputs.changed == 'true'
107+
working-directory: pr
108+
env:
109+
HEAD_REF: ${{ steps.pr.outputs.head_ref }}
110+
PUSH_TOKEN: >-
111+
${{ steps.pr.outputs.head_repository == github.repository &&
112+
github.token ||
113+
secrets.MAINTAINER_TOKEN }}
114+
run: |
115+
set -euo pipefail
116+
if [[ -z "$PUSH_TOKEN" ]]; then
117+
echo "MAINTAINER_TOKEN is required to push to fork PR branches." >&2
118+
exit 1
119+
fi
120+
git config user.name "github-actions[bot]"
121+
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
122+
git add -- icons
123+
git commit -m "Format icons"
124+
git -c "http.extraheader=AUTHORIZATION: bearer $PUSH_TOKEN" \
125+
push origin "HEAD:$HEAD_REF"

‎.github/workflows/validate-plugin-submission.yml‎

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,21 @@ jobs:
1616
runs-on: ubuntu-latest
1717
steps:
1818
- name: Check out pull request
19-
uses: actions/checkout@v4
19+
uses: actions/checkout@v7
2020
with:
2121
fetch-depth: 0
2222

2323
- name: Set up Python
24-
uses: actions/setup-python@v5
24+
uses: actions/setup-python@v7
2525
with:
2626
python-version: "3.x"
2727

2828
- name: Validate catalogue submission
2929
env:
3030
GITHUB_TOKEN: ${{ github.token }}
31-
run: python validate_submission.py --base "${{ github.event.pull_request.base.sha }}" --head "${{ github.event.pull_request.head.sha }}"
31+
run: >-
32+
python validate_submission.py
33+
--base "${{ github.event.pull_request.base.sha }}"
34+
--head "${{ github.event.pull_request.head.sha }}"
35+
--author "${{ github.event.pull_request.user.login }}"
36+
--repository "${{ github.repository }}"

0 commit comments

Comments
 (0)