Skip to content

Commit 998be76

Browse files
committed
Mixxx control types export script & workflow
1 parent 863f030 commit 998be76

File tree

2 files changed

+679
-0
lines changed

2 files changed

+679
-0
lines changed
Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow
2+
3+
name: Generate TypeScript Control Types
4+
5+
on:
6+
push:
7+
branches:
8+
- '**'
9+
10+
permissions: {}
11+
env:
12+
MIXXXBOT_TS_TYPES_AUTOUPDATER_PAT: ${{ secrets.MIXXXBOT_TS_TYPES_AUTOUPDATER_PAT }}
13+
jobs:
14+
build-and-deploy-ts-control-types:
15+
runs-on: ubuntu-latest
16+
steps:
17+
- name: Checkout Manual
18+
uses: actions/checkout@v6
19+
with:
20+
path: manual
21+
22+
- name: Checkout Mixxx
23+
if: env.MIXXXBOT_TS_TYPES_AUTOUPDATER_PAT != null
24+
uses: actions/checkout@v6
25+
with:
26+
repository: mixxxdj/mixxx
27+
token: ${{ env.MIXXXBOT_TS_TYPES_AUTOUPDATER_PAT }}
28+
path: mixxx
29+
ref: ${{ github.ref_name }}
30+
31+
- name: Build Manual
32+
working-directory: manual
33+
run: |
34+
pip install -r requirements.txt
35+
pip install pre-commit
36+
make html
37+
38+
- name: Run Generator
39+
working-directory: manual
40+
run: |
41+
python tools/ts_export_docs_controls.py
42+
43+
- name: 'Check if update branch already exists'
44+
if: env.MIXXXBOT_TS_TYPES_AUTOUPDATER_PAT != null
45+
id: check_sync
46+
working-directory: mixxx
47+
run: |
48+
if git fetch origin "${SYNC_BRANCH}"; then
49+
echo "Branch ${SYNC_BRANCH} already exists, checking if the branch was modified..."
50+
echo "branch_exists=true" >> $GITHUB_OUTPUT
51+
COMMITTER_EMAIL="$(git show --pretty=format:"%ce" --no-patch "origin/${SYNC_BRANCH}")"
52+
if [ "${COMMITTER_EMAIL}" = "${SYNC_COMMITTER_EMAIL}" ]; then
53+
echo "Branch ${SYNC_BRANCH} was NOT modified."
54+
else
55+
echo "Branch ${SYNC_BRANCH} was modified."
56+
fi
57+
else
58+
echo "Branch ${SYNC_BRANCH} does not exist yet."
59+
echo "branch_exists=false" >> $GITHUB_OUTPUT
60+
fi
61+
env:
62+
SYNC_COMMITTER_EMAIL: bot@mixxx.org
63+
SYNC_COMMITTER_NAME: Mixxx Bot
64+
SYNC_BRANCH: ts-definitions-update-${{ github.ref_name }}
65+
66+
- name: 'Push Changes if any'
67+
if: env.MIXXXBOT_TS_TYPES_AUTOUPDATER_PAT != null
68+
working-directory: mixxx
69+
run: |
70+
set -x
71+
72+
git fetch origin "${TO_BRANCH}"
73+
if [ "${BRANCH_EXISTS}" = true ]; then
74+
git switch -C "${SYNC_BRANCH}" "origin/${SYNC_BRANCH}"
75+
else
76+
git switch -C "${SYNC_BRANCH}" "origin/${TO_BRANCH}"
77+
fi
78+
79+
cp ../manual/build/mixxx-controls.d.ts res/controllers/mixxx-controls.d.ts
80+
git add res/controllers/mixxx-controls.d.ts
81+
82+
# Run pre-commit to format and stage
83+
pre-commit run --files res/controllers/mixxx-controls.d.ts || true
84+
git add res/controllers/mixxx-controls.d.ts
85+
86+
if git diff --cached --quiet; then
87+
echo "No changes detected!"
88+
git status
89+
exit 0
90+
fi
91+
92+
git config --global user.email "${SYNC_COMMITTER_EMAIL}"
93+
git config --global user.name "${SYNC_COMMITTER_NAME}"
94+
95+
git commit -m "Update TypeScript definitions"
96+
git push origin "${SYNC_BRANCH}"
97+
gh pr create -B "${TO_BRANCH}" -H "${SYNC_BRANCH}" --title "${PULL_REQUEST_TITLE}" --body "${PULL_REQUEST_BODY}" || true
98+
gh pr edit --add-label "sync-branches" # We can use the same label for now
99+
env:
100+
BRANCH_EXISTS: ${{ steps.check_sync.outputs.branch_exists }}
101+
SYNC_COMMITTER_EMAIL: bot@mixxx.org
102+
SYNC_COMMITTER_NAME: Mixxx Bot
103+
SYNC_BRANCH: ts-definitions-update-${{ github.ref_name }}
104+
TO_BRANCH: ${{ github.ref_name }}
105+
GITHUB_TOKEN: ${{ env.MIXXXBOT_TS_TYPES_AUTOUPDATER_PAT }}
106+
PULL_REQUEST_TITLE: New Typescript definitions for COs on `${{ github.ref_name }}`
107+
PULL_REQUEST_BODY: |
108+
New COs definitions was generated with the latest manual changes (${{ github.sha }}), so let's merge the changes into `${{ github.ref_name }}`

0 commit comments

Comments
 (0)