-
Notifications
You must be signed in to change notification settings - Fork 37
101 lines (93 loc) · 3.29 KB
/
transformDataToViews.yml
File metadata and controls
101 lines (93 loc) · 3.29 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
name: Transform NVDA addons to views
on:
workflow_call:
workflow_dispatch:
concurrency:
group: transform
cancel-in-progress: true
jobs:
transformAndPush:
runs-on: ubuntu-latest
defaults:
run:
shell: bash
permissions:
contents: write
pull-requests: write
env:
# this is a git '--pretty=format' string
# %h is SHA, %n is newline,
# %s is commit message subject, %b is commit message body
COMMIT_FORMAT: "Generated from %h%n%nCommit message:%n%s%n%b"
strategy:
matrix:
python-version: [ 3.13 ]
steps:
- name: Checkout addon data
uses: actions/checkout@v5
with:
submodules: true
- name: Checkout addonstore-views repository
uses: actions/checkout@v5
with:
repository: nvaccess/addonstore-views
path: views
ref: main
token: ${{ secrets.VIEWS_PUSH_TOKEN }}
- name: Install system deps for lxml
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends \
libxml2-dev libxslt1-dev zlib1g-dev
- name: Install the latest version of uv
uses: astral-sh/setup-uv@v6
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install requirements and run transformation
run: |
set -euo pipefail
uv sync
# generate transformed data from this repository's addons metadata
rm -rf generated/
uv run --directory transform python -m src.transform --loglevel "${{ env.logLevel }}" nvdaAPIVersions.json ../addons ../generated
# replace generated data directories in addonstore-views
rm -rf views/addons/ views/views/
cp -R generated/addons views/addons
cp -R generated/views views/views
env:
logLevel: ${{ runner.debug && 'DEBUG' || 'INFO' }}
- name: Copy files
run: |
set -euo pipefail
cp ./transform/nvdaAPIVersions.json ./views/nvdaAPIVersions.json
cp ./transform/docs/output.md ./views/output.md
cp ./README.md ./views/README.md
- name: Create PR and enable auto-merge
env:
GH_TOKEN: ${{ secrets.VIEWS_PUSH_TOKEN }}
run: |
set -euo pipefail
git log HEAD --pretty=format:"${{ env.COMMIT_FORMAT }}" -1 > commitMsg.txt
cd views
git config user.name github-actions
git config user.email github-actions@github.com
git add .
if git diff --staged --quiet; then
echo "No generated changes; skipping PR creation."
exit 0
fi
branchName="transformViews${{ github.run_id }}-${{ github.run_attempt }}"
git checkout -b "$branchName"
# TODO: Temporarily suppress output during first commit as testing logs are too big.
# Remove quiet and gpg sign flags later.
git commit --quiet --no-gpg-sign -F ../commitMsg.txt
git push --set-upstream origin "$branchName"
prUrl=$(gh pr create \
--repo nvaccess/addonstore-views \
--base main \
--head "$branchName" \
--title "[Automated] Transform add-on data to views" \
--body-file ../commitMsg.txt)
gh pr merge --auto --squash --delete-branch "$prUrl"