-
Notifications
You must be signed in to change notification settings - Fork 4
114 lines (96 loc) · 3.6 KB
/
wp-i18n.yml
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
name: WP Internationalization
on:
pull_request:
types: [opened, edited, synchronize, reopened, ready_for_review]
branches:
- 'trunk'
concurrency:
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }}
cancel-in-progress: true
jobs:
wp-i18n:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: ${{ github.ref }}
- name: Setup workflow context
id: workflow
working-directory: ${{ runner.temp }}
env:
REPO: ${{ github.repository }}
run: |
mkdir dist
echo "DIST=${PWD}/dist" >> $GITHUB_OUTPUT
echo "PACKAGE=${REPO##*/}" >> $GITHUB_OUTPUT
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: "7.4"
coverage: none
tools: composer
- name: Get Composer cache directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- name: Cache Composer vendor directory
uses: actions/cache@v3
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 18
- name: Cache node modules
uses: actions/cache@v3
env:
cache-name: cache-node-modules
with:
path: ~/.npm
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: Log debug information
run: |
php --version
composer --version
node --version
npm --version
- name: Validate composer.json and composer.lock files
run: composer validate
- name: Install PHP Dependencies
run: composer install --no-progress --optimize-autoloader
- name: Setup Registry
run: printf "\n//npm.pkg.github.com/:_authToken=${{ secrets.NEWFOLD_ACCESS_TOKEN }}" >> .npmrc
- name: Run NPM Install
run: npm install
- name: Build dist
run: npm run build
- name: Remove token
run: git checkout -- '.npmrc'
- name: Add text domains
run: npx node-wp-i18n addtextdomain
- name: Generate POT file
run: vendor/bin/wp i18n make-pot . ./languages/${{ github.event.repository.name }}.pot --headers='{"Report-Msgid-Bugs-To":"https://github.com/${{ github.repository }}/issues","POT-Creation-Date":null}' --exclude=node_modules,tests
- name: Check if there are file changes
id: changes
run: echo "changed=$(git status --porcelain | wc -l)" >> $GITHUB_OUTPUT
- name: Commit web files
if: steps.changes.outputs.changed != 0
run: |
git config --local user.name "${{ github.event.head_commit.author.name }}"
git config --local user.email "${{ github.event.head_commit.author.email }}"
git remote -v
git add -A
git commit -m "WordPress I18N triggered by commit ${{ github.sha }}"
git status
- name: Push changes
if: steps.changes.outputs.changed != 0
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}