Fetch iTunes Country codes #570
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Fetch iTunes Country codes | |
on: | |
push: | |
branches: | |
- main | |
- dev | |
paths-ignore: | |
- '**/README.md' | |
pull_request: | |
branches: | |
- main | |
- dev | |
schedule: | |
- cron: "59 23 * * 1-5" # 23:59 UTC every Monday to Friday | |
permissions: | |
contents: write | |
jobs: | |
fetch-chunks: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
# split task into parallel chunks to avoid iTunes Search API throttling | |
chunks: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11] | |
env: | |
total_chunks: 12 | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Set up Python 3.10 | |
uses: actions/setup-python@v5 | |
with: | |
python-version: "3.10" | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
python -m pip install requests | |
- name: Fetch iTunes Country codes | |
run: python script/fetch_itunes_country_codes.py $total_chunks ${{matrix.chunks}} > ./c_${{matrix.chunks}}.json | |
- name: Upload chunks | |
uses: actions/upload-artifact@v4 | |
with: | |
name: chunks-${{ matrix.chunks }} | |
path: ./c_${{matrix.chunks}}.json | |
combine: | |
runs-on: ubuntu-latest | |
needs: [fetch-chunks] | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Set up Python 3.10 | |
uses: actions/setup-python@v5 | |
with: | |
python-version: "3.10" | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
python -m pip install pandas | |
- name: Get current date | |
id: date | |
run: echo "date=$(date +'%Y-%b-%d')" >> $GITHUB_OUTPUT | |
- name: Download all fetched chunks | |
uses: actions/download-artifact@v4 | |
with: | |
pattern: chunks-* | |
merge-multiple: true | |
- name: Combine chunks | |
id: changes | |
run: | | |
echo "CHANGELOG<<EOF" >> $GITHUB_ENV | |
python script/combine_chunks.py >> $GITHUB_ENV | |
echo "EOF" >> $GITHUB_ENV | |
- name: Auto-commit changes | |
uses: stefanzweifel/git-auto-commit-action@v5 | |
with: | |
commit_message: "(Automated) Updated iTunes Country codes" | |
file_pattern: 'itunes_country_codes.json' | |
- name: Release | |
uses: softprops/action-gh-release@v2 | |
if: env.CHANGELOG != 'identical' | |
with: | |
files: itunes_country_codes.json | |
name: ${{ steps.date.outputs.date }} | |
tag_name: ${{ steps.date.outputs.date }} | |
body: ${{ env.CHANGELOG }} |