Skip to content

Commit

Permalink
Auto Update Locale Files (#780)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
dpgraham4401 authored May 1, 2024
1 parent 509f2b1 commit 3b71b89
Showing 1 changed file with 36 additions and 52 deletions.
88 changes: 36 additions & 52 deletions .github/workflows/i18n.yml
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 3b71b89

Please sign in to comment.