From 3b71b89779043acd865f13547d88b8355e4ef525 Mon Sep 17 00:00:00 2001 From: David Paul Graham <43794491+dpgraham4401@users.noreply.github.com> Date: Wed, 1 May 2024 12:43:12 -0400 Subject: [PATCH] Auto Update Locale Files (#780) * update workflow permissions to create PR to trunk when locales need to be updated and clean up the workflow with newer dependencies including: python 3.9 -> 3.12 GH action/checkout@v2 -> action/checkout@v4 create-pull-request@v3 -> create-pull-requests@v6 actions/setup-python@v2 -> actions/setup-python@v5 With the updated dependencies we now cache python dependencies with the built-in functionality. We also only run this action if it's push to the jazzband org repo * add 'delete-branch' to auto delete PR branch after updating locale files * move permissions into job scope --- .github/workflows/i18n.yml | 88 ++++++++++++++++---------------------- 1 file changed, 36 insertions(+), 52 deletions(-) diff --git a/.github/workflows/i18n.yml b/.github/workflows/i18n.yml index 0caa13533..411f80702 100644 --- a/.github/workflows/i18n.yml +++ b/.github/workflows/i18n.yml @@ -1,63 +1,47 @@ -name: Locale Updater +name: Update locale files on: push: branches: - - master - main + - master + jobs: locale-updater: - name: Locale updater - runs-on: ubuntu-latest permissions: pull-requests: write + contents: write + if: github.repository == 'jazzband/djangorestframework-simplejwt' + name: Locale updater + runs-on: ubuntu-latest steps: - - name: Checkout repo - uses: actions/checkout@v2 - with: - ref: ${{ github.head_ref }} - - - name: Set up Python 3.9 - uses: actions/setup-python@v2 - with: - python-version: '3.9' - - - name: Get pip cache dir - id: pip-cache - run: | - echo "::set-output name=dir::$(pip cache dir)" - - - name: Cache - uses: actions/cache@v2 - with: - path: ${{ steps.pip-cache.outputs.dir }} - key: - 3.9-v1-${{ hashFiles('**/setup.py') }} - restore-keys: | - 3.9-v1- - - - name: Install dependencies - run: | - sudo apt-get install -y gettext - python -m pip install --upgrade pip wheel setuptools - pip install -e .[dev] - - - name: Run locale - working-directory: rest_framework_simplejwt - run: | - python ../scripts/i18n_updater.py - - - name: Create Pull Request - uses: peter-evans/create-pull-request@v5 - id: auto-commit-action - with: - branch: i18n-auto-update - title: "[i18n] Update" - body: "Updated locale files on master branch" - commit-message: "Update locale files" - add-paths: rest_framework_simplejwt/locale/** - delete-branch: true - - - name: Tell whether locale updated - run: echo "Locale files updated" + + - name: Checkout Repository + uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: '3.12' + cache: 'pip' + cache-dependency-path: setup.py + + - name: Install dependencies + run: | + sudo apt-get install -y gettext + python -m pip install --upgrade pip wheel setuptools + pip install -e .[dev] + + - name: Run locale Update Script + run: python scripts/i18n_updater.py + + - name: Create Pull Request + uses: peter-evans/create-pull-request@v6 + with: + branch: i18n-auto-update + title: "[i18n] Update" + body: "Updated locale files on trunk" + commit-message: "Update locale files" + add-paths: rest_framework_simplejwt/locale/** + delete-branch: true