Skip to content

Install wp-cli using php phar #8

Install wp-cli using php phar

Install wp-cli using php phar #8

Workflow file for this run

name: Run GPT-PO Command
on:
push:
branches:
- master # Runs the workflow on push to the master branch
jobs:
run-gpt-po:
runs-on: ubuntu-latest
steps:
- name: Check out the code
uses: actions/checkout@v3
with:
fetch-depth: 0 # Fetch all history for accurate commit history
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '16' # Adjust this to your project's Node.js version
- name: Install gpt-po
run: npm install gpt-po # Installs `gpt-po` package locally in `node_modules`
- name: Install WP-CLI
run: |
curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/installer.sh
chmod +x installer.sh
bash installer.sh --install-dir=/usr/local/bin --filename=wp
wp --info # Verify WP-CLI installation
- name: Run GPT-PO Command
env:
API_KEY: ${{ secrets.OPENAI_API_KEY }}
run: |
npx gpt-po --dir languages --key $API_KEY
echo "Translation completed."
- name: Generate PHP Files
run: |
wp i18n make-php languages
echo "PHP files generated from translations."
- name: Generate JSON Files
run: |
wp i18n make-json languages
echo "JSON files generated from translations."
- name: Check Git Status
run: git status # Check if .po files were modified
- name: Commit and Push Changes
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
if [ -n "$(git status --porcelain)" ]; then
git add languages/*.po languages/*.php languages/*.json
git commit -m "Update .po, .php, and .json files with new translations"
git push
else
echo "No changes to commit"
fi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}