Files
trash/.github/workflows/sync.yml
T

149 lines
4.3 KiB
YAML

name: Sync TRaSH Guides
on:
schedule:
- cron: '0 0 * * *'
workflow_dispatch:
jobs:
sync:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
target:
- name: full
branch: main
profiles: ''
- name: standard
branch: standard
profiles: |
HD Bluray + WEB
Remux + WEB 1080p
Remux + WEB 2160p
Remux 2160p (Alternative)
Remux 2160p (Combined)
UHD Bluray + WEB
WEB-1080p
WEB-1080p (Alternative)
WEB-2160p
WEB-2160p (Alternative)
WEB-2160p (Combined)
- name: anime
branch: anime
profiles: |
[Anime] Remux-1080p
- name: french
branch: french
profiles: |
[French MULTi.VO] HD Bluray + WEB
[French MULTi.VO] HD Remux (1080p)
[French MULTi.VO] UHD Bluray + WEB
[French MULTi.VO] UHD Remux (2160p)
[French MULTi.VO] HD Bluray + WEB (1080p)
[French MULTi.VO] UHD Bluray + WEB (2160p)
- name: german
branch: german
profiles: |
[German] HD Bluray + WEB
[German] HD Remux + WEB
[German] Remux + WEB 2160p
[German] UHD Bluray + WEB
[German] UHD Bluray + WEB (Alternative)
[German] UHD Remux + WEB
- name: sqp
branch: sqp
profiles: |
[SQP] SQP-1 (1080p)
[SQP] SQP-1 (2160p)
[SQP] SQP-1 WEB (1080p)
[SQP] SQP-1 WEB (2160p)
[SQP] SQP-2
[SQP] SQP-3
[SQP] SQP-3 (Audio)
[SQP] SQP-4
[SQP] SQP-5
steps:
- name: Checkout trash-pcd (${{ matrix.target.branch }} branch)
uses: actions/checkout@v4
with:
token: ${{ secrets.ORG_PAT }}
ref: ${{ matrix.target.branch }}
path: trash-pcd
- name: Clone TRaSH Guides
uses: actions/checkout@v4
with:
repository: TRaSH-Guides/Guides
path: Guides
- name: Clone Schema
uses: actions/checkout@v4
with:
repository: Dictionarry-Hub/schema
token: ${{ secrets.ORG_PAT }}
path: schema
- name: Clone trash-conv
uses: actions/checkout@v4
with:
repository: Dictionarry-Hub/trash-conv
token: ${{ secrets.ORG_PAT }}
path: trash-conv
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Install dependencies
working-directory: trash-conv
run: npm ci
- name: Save current version
working-directory: trash-pcd
run: cp pcd.json pcd.json.bak 2>/dev/null || true
- name: Run converter
working-directory: trash-conv
run: |
profile_args=()
while IFS= read -r profile; do
profile=$(printf '%s' "$profile" | sed -E 's/^[[:space:]]+//; s/[[:space:]]+$//')
if [ -n "$profile" ]; then
profile_args+=(-p "$profile")
fi
done <<'EOF'
${{ matrix.target.profiles }}
EOF
npx tsx src/index.ts \
-i ../Guides \
-o ../trash-pcd \
-s ../schema \
"${profile_args[@]}"
- name: Check for changes
id: changes
working-directory: trash-pcd
run: |
if git diff --ignore-matching-lines='^-- Generated:' --quiet -- ops/1.initial.sql; then
echo "changed=false" >> $GITHUB_OUTPUT
mv pcd.json.bak pcd.json 2>/dev/null || true
else
echo "changed=true" >> $GITHUB_OUTPUT
rm -f pcd.json.bak
fi
- name: Commit and push
if: steps.changes.outputs.changed == 'true'
working-directory: trash-pcd
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
new_version=$(jq -r .version pcd.json)
git add -A
git commit -m "chore: sync ${{ matrix.target.name }} (v${new_version})"
git push