|
| 1 | +name: Weekly Update TMDB Collections |
| 2 | + |
| 3 | +on: |
| 4 | + schedule: |
| 5 | + - cron: "0 12 * * 0" # Every Sunday at 12 PM |
| 6 | + workflow_dispatch: |
| 7 | + |
| 8 | +jobs: |
| 9 | + update-collection-ids: |
| 10 | + permissions: write-all |
| 11 | + runs-on: ubuntu-latest |
| 12 | + steps: |
| 13 | + - name: Checkout code |
| 14 | + uses: actions/checkout@v4 |
| 15 | + - name: Delete action/collection_ids branch if present |
| 16 | + run: | |
| 17 | + git push --delete origin action/collection_ids || true |
| 18 | + - name: Download gzipped JSON file |
| 19 | + run: | |
| 20 | + 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 |
| 21 | + - name: Wait for download to complete |
| 22 | + run: | |
| 23 | + while [ ! -f download_complete ]; do sleep 1; done |
| 24 | + - name: Check if downloaded file exists |
| 25 | + run: | |
| 26 | + if [ -f collection_ids.json.gz ]; then |
| 27 | + gunzip collection_ids.json.gz |
| 28 | + else |
| 29 | + echo "Error: Downloaded file not found" |
| 30 | + exit 1 |
| 31 | + fi |
| 32 | + - name: Add trailing comma and brackets to collection_ids.json |
| 33 | + run: | |
| 34 | + sed -i -e '$!s/$/,/' collection_ids.json |
| 35 | + echo "[" > temp.json && cat collection_ids.json >> temp.json && echo "]" >> temp.json && mv temp.json collection_ids.json |
| 36 | + - name: Copy JSON file to src/assets |
| 37 | + run: | |
| 38 | + cp collection_ids.json src/assets/collection_ids.json |
| 39 | + - name: Remove downloaded file from root |
| 40 | + run: | |
| 41 | + rm -f download_complete collection_ids.json.gz collection_ids |
| 42 | + - name: Git config |
| 43 | + run: | |
| 44 | + git config --global user.email "<41898282+github-actions[bot]@users.noreply.github.com>" |
| 45 | + git config --global user.name "github-actions[bot]" |
| 46 | + - name: Commit and push changes |
| 47 | + run: | |
| 48 | + git checkout -b action/collection_ids |
| 49 | + git add src/assets/collection_ids.json |
| 50 | + git commit -m "chore(assets)[github-actions] : Update collection_ids.json for $(date -d 'yesterday' +\%m_%d_%Y)" |
| 51 | + git push origin action/collection_ids |
| 52 | + env: |
| 53 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 54 | + # - name: Create pull request |
| 55 | + # uses: peter-evans/create-pull-request@v3 |
| 56 | + # with: |
| 57 | + # token: ${{ secrets.GITHUB_TOKEN }} |
| 58 | + # title: "chore(assets)[github-actions] : Update collection_ids.json" |
| 59 | + # body: "Automatically updating collection_ids.json file for latest TMDB collections" |
| 60 | + # labels: "📦 dependencies" |
| 61 | + # base: dev |
| 62 | + # branch: action/collection_ids |
| 63 | + - name: Create pull request |
| 64 | + uses: devops-infra/action-pull-request@v0.5.5 |
| 65 | + with: |
| 66 | + github_token: ${{ secrets.GITHUB_TOKEN }} |
| 67 | + source_branch: action/collection_ids |
| 68 | + target_branch: dev |
| 69 | + title: ${{ github.event.commits[0].message }} |
| 70 | + body: "Automatically updating collection_ids.json file for latest TMDB collections" |
| 71 | + assignee: ${{ github.actor }} |
| 72 | + reviewer: dev-AshishRanjan |
| 73 | + label: 📦 dependencies |
| 74 | + get_diff: true |
0 commit comments