Merge branch 'master' of github.com:sanzeeb3/wp-frontend-delete-account #1
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 Automate Translations | |
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: | |
persist-credentials: false # For security, don't persist credentials | |
fetch-depth: 0 # Fetch all history for accurate commit | |
- 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/phar/wp-cli.phar | |
chmod +x wp-cli.phar | |
sudo mv wp-cli.phar /usr/local/bin/wp | |
wp --info # Verify WP-CLI installation | |
- name: Generate POT file | |
run: wp i18n make-pot . languages/aawp.pot --exclude=assets/block/src | |
- name: Run GPT-PO Command | |
env: | |
API_KEY: ${{ secrets.OPENAI_API_KEY }} | |
run: npx gpt-po --dir languages --key $API_KEY | |
- name: Run WP-CLI Commands | |
run: | | |
wp i18n make-php languages | |
wp i18n make-json languages | |
- 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" | |
git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }} | |
git add languages # Stage changes only in the languages directory | |
if [ -n "$(git status --porcelain)" ]; then | |
git commit -m "Update translation files with new translations" | |
git push | |
else | |
echo "No changes to commit" | |
fi | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |