Skip to content

Weekly Update TMDB Collections #12

Weekly Update TMDB Collections

Weekly Update TMDB Collections #12

Workflow file for this run

name: Weekly Update TMDB Collections
on:
schedule:
- cron: "0 12 * * 0" # Every Sunday at 12 PM
workflow_dispatch:
jobs:
update-collection-ids:
permissions: write-all
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Delete action/collection_ids branch if present
run: |
git push --delete origin action/collection_ids || true
- name: Download gzipped JSON file
run: |
curl -L -o collection_ids.json.gz http://files.tmdb.org/p/exports/collection_ids_$(date -d 'yesterday' +\%m_%d_%Y).json.gz && touch download_complete
- name: Wait for download to complete
run: |
while [ ! -f download_complete ]; do sleep 1; done
- name: Check if downloaded file exists
run: |
if [ -f collection_ids.json.gz ]; then
gunzip collection_ids.json.gz
else
echo "Error: Downloaded file not found"
exit 1
fi
- name: Add trailing comma and brackets to collection_ids.json
run: |
sed -i -e '$!s/$/,/' collection_ids.json
echo "[" > temp.json && cat collection_ids.json >> temp.json && echo "]" >> temp.json && mv temp.json collection_ids.json
- name: Copy JSON file to src/assets
run: |
cp collection_ids.json src/assets/collection_ids.json
- name: Remove downloaded file from root
run: |
rm -f download_complete collection_ids.json.gz collection_ids
- name: Git config
run: |
git config --global user.email "<41898282+github-actions[bot]@users.noreply.github.com>"
git config --global user.name "github-actions[bot]"
- name: Commit and push changes
run: |
git checkout -b action/collection_ids
git add src/assets/collection_ids.json
git commit -m "chore(assets)[github-actions] : Update collection_ids.json for $(date -d 'yesterday' +\%m_%d_%Y)"
git push origin action/collection_ids
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# - name: Create pull request
# uses: peter-evans/create-pull-request@v3
# with:
# token: ${{ secrets.GITHUB_TOKEN }}
# title: "chore(assets)[github-actions] : Update collection_ids.json"
# body: "Automatically updating collection_ids.json file for latest TMDB collections"
# labels: "📦 dependencies"
# base: dev
# branch: action/collection_ids
- name: Create pull request
uses: devops-infra/action-pull-request@v0.5.5
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
source_branch: action/collection_ids
target_branch: dev
title: ${{ github.event.commits[0].message }}
body: "Automatically updating collection_ids.json file for latest TMDB collections"
assignee: ${{ github.actor }}
reviewer: dev-AshishRanjan
label: 📦 dependencies
get_diff: true