Merge branch 'master' of github.com:sanzeeb3/wp-frontend-delete-account #7
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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/keys/cli.key | |
curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/keys/cli.pub | |
curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/installer.sh | |
chmod +x installer.sh | |
./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 }} |