-
Notifications
You must be signed in to change notification settings - Fork 30
159 lines (146 loc) · 5.16 KB
/
pull-locales.yml
File metadata and controls
159 lines (146 loc) · 5.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
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.5
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.