48 lines
1.5 KiB
YAML
48 lines
1.5 KiB
YAML
name: Update mods.json
|
|
|
|
on:
|
|
workflow_dispatch:
|
|
|
|
jobs:
|
|
update-mods:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
|
|
- name: Setup Git
|
|
run: |
|
|
git config --global user.name "Gitea Action"
|
|
git config --global user.email "action@gitea.local"
|
|
|
|
- name: Get list of .zip files via API
|
|
env:
|
|
GITEA_TOKEN: ${{ secrets.gamerarena }}
|
|
GITEA_API_URL: https://git.garpnet.it/api/v1
|
|
OWNER: GamerArena
|
|
REPO: FastDL
|
|
BRANCH: main
|
|
run: |
|
|
# Prende la lista di file nella root del repo
|
|
response=$(curl -s -H "Authorization: token $GITEA_TOKEN" \
|
|
"$GITEA_API_URL/repos/$OWNER/$REPO/contents?ref=$BRANCH")
|
|
|
|
# Filtra solo i file .zip e crea array JSON
|
|
zip_files=$(echo "$response" | jq -r '.[] | select(.type=="file") | select(.name|endswith(".zip")) | .name')
|
|
json_array=$(echo "$zip_files" | jq -R -s -c 'split("\n")[:-1]')
|
|
|
|
echo "Lista file .zip: $json_array"
|
|
|
|
# Scrive mods.json
|
|
echo "$json_array" > mods.json
|
|
|
|
- name: Commit and push mods.json
|
|
env:
|
|
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
|
|
run: |
|
|
# Clona repo temporaneamente
|
|
git clone https://git.garpnet.it/GamerArena/FastDL.git
|
|
|
|
|
|
# Commit e push
|
|
git add mods.json
|
|
git commit -m "Update mods.json with .zip files"
|
|
git push origin main |