Skip to content

Pull locales from POEditor #15817

Pull locales from POEditor

Pull locales from POEditor #15817

Workflow file for this run

name: Pull locales from POEditor
on:
workflow_dispatch:
inputs:
poeditor_project_id:
required: true
description: "POEditor Project ID"
type: number
schedule:
- cron: "0 * * * *"
env:
PHP_VERSION: 8.4
permissions:
contents: read
concurrency:
group: pull-locales
cancel-in-progress: true
jobs:
pull-locales:
name: Pull locales from POEditor
runs-on: ubuntu-latest
permissions:
contents: read
outputs:
has_changes: ${{ steps.locale-changes.outputs.has_changes }}
services:
mariadb:
image: mariadb:11
ports:
- 3306
env:
MARIADB_USER: user
MARIADB_PASSWORD: password
MARIADB_DATABASE: test
MARIADB_ROOT_PASSWORD: password
options: --health-cmd="healthcheck.sh --connect --innodb_initialized" --health-interval=5s --health-timeout=2s --health-retries=3
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 2
persist-credentials: false
- name: Verify MariaDB connection
env:
PORT: ${{ job.services.mariadb.ports[3306] }}
run: |
while ! mysqladmin ping -h"127.0.0.1" -P"$PORT" --silent; do
sleep 1
done
- name: Setup PHP, with composer and extensions
uses: shivammathur/setup-php@accd6127cb78bee3e8082180cb391013d204ef9f # 2.37.0
with:
php-version: ${{ env.PHP_VERSION }}
extensions: bcmath, ctype, fileinfo, json, mbstring, dom, ldap, pdo, tokenizer, xml, mysql, sqlite
coverage: pcov
- name: Copy .env
run: php -r "copy('.env.ci', '.env');"
- name: Get Composer Cache Directory
id: composer-cache
run: |
echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-
- name: Install php dependencies
run: |
composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist
- name: Generate key
run: php artisan key:generate
- name: Directory Permissions
run: chmod -R 777 storage bootstrap/cache
- name: Migrate Database
env:
DB_HOST: 127.0.0.1
DB_PORT: ${{ job.services.mariadb.ports[3306] }}
DB_DATABASE: test
DB_USERNAME: root
DB_PASSWORD: password
run: php artisan migrate --no-interaction -vvv --force
- name: Execute command to pull locales from POEditor
env:
DB_HOST: 127.0.0.1
DB_PORT: ${{ job.services.mariadb.ports[3306] }}
DB_DATABASE: test
DB_USERNAME: root
DB_PASSWORD: password
POEDITOR_TOKEN: ${{ secrets.POEDITOR_TOKEN }}
POEDITOR_PROJECT: ${{ github.event.inputs.poeditor_project_id || secrets.POEDITOR_PROJECT}}
run: php artisan locales:import
- name: Detect locale changes
id: locale-changes
run: |
git add -A lang
if git diff --cached --quiet; then
echo "has_changes=false" >> "$GITHUB_OUTPUT"
echo "No locale changes detected."
else
echo "has_changes=true" >> "$GITHUB_OUTPUT"
git diff --cached --binary -- lang > locale.patch
fi
- name: Report no changes
if: steps.locale-changes.outputs.has_changes == 'false'
run: |
{
echo "## Locale update result"
echo
echo 'No changes detected in `lang/**/*.php`.'
echo "PR creation was skipped."
} >> "$GITHUB_STEP_SUMMARY"
- name: Upload locale patch
if: steps.locale-changes.outputs.has_changes == 'true'
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: locale-patch
path: locale.patch
create-locales-pr:
name: Create locales PR
runs-on: ubuntu-latest
needs: pull-locales
if: needs.pull-locales.outputs.has_changes == 'true'
permissions:
contents: write
pull-requests: write
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 2
persist-credentials: false
- name: Download locale patch
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: locale-patch
- name: Apply locale patch
run: git apply --index locale.patch
- name: Create Pull Request
uses: peter-evans/create-pull-request@5f6978faf089d4d20b00c7766989d076bb2fc7f1 # v8.1.1
with:
commit-message: Update locales
add-paths: "lang/**/*.php"
branch: update-locales
title: Update locales using POEditor
body: This PR was automatically created using the most recent translations from POEditor.