Update International Phrases #1362
This file contains hidden or 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
| # This workflow will run tests using node and then publish a package to GitHub Packages when a release is created | |
| # For more information see: https://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages | |
| name: Update International Phrases | |
| on: workflow_dispatch | |
| jobs: | |
| phrases: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v3 | |
| - uses: actions/setup-node@v3 | |
| with: | |
| node-version: 16 | |
| - name: Set commit account information | |
| run: | | |
| git config --global user.name "github-actions[bot]" | |
| git config --global user.email "github-actions[bot]@users.noreply.github.com" | |
| - name: Installations | |
| run: | | |
| git submodule update --init --recursive | |
| npm run setup | |
| - name: Decrypt credentials | |
| run: | | |
| gpg --quiet --batch --yes --passphrase="${{secrets.google_api_pw}}" \ | |
| --output docs/experiment/threshold/server/credentials.json \ | |
| --decrypt docs/experiment/threshold/server/credentials.json.gpg | |
| - name: Fetch and update phrases | |
| id: fetch_phrases | |
| run: | | |
| cd docs/experiment/threshold | |
| npm run phrases | |
| git status | |
| git add -A | |
| # Check if there are changes to commit | |
| if git diff --cached --quiet; then | |
| echo "No phrase changes detected" | |
| echo "phrases_updated=false" >> $GITHUB_OUTPUT | |
| else | |
| git commit -m 'github action: update phrases' --no-verify | |
| git remote set-url origin https://x-access-token:${{secrets.ci_token}}@github.com/EasyEyes/threshold | |
| git push | |
| echo "phrases_updated=true" >> $GITHUB_OUTPUT | |
| fi | |
| cd .. | |
| git add -A | |
| if ! git diff --cached --quiet; then | |
| git commit -m 'github action: update phrases' --no-verify | |
| git remote set-url origin https://x-access-token:${{secrets.ci_token}}@github.com/EasyEyes/threshold-scientist | |
| git push | |
| fi | |
| cd .. | |
| git add -A | |
| if ! git diff --cached --quiet; then | |
| git commit -m 'github action: update phrases' --no-verify | |
| git remote set-url origin https://x-access-token:${{secrets.ci_token}}@github.com/${{github.repository}} | |
| git push | |
| fi | |
| - name: Notify Slack on success (phrases updated) | |
| if: success() && steps.fetch_phrases.outputs.phrases_updated == 'true' | |
| uses: slackapi/[email protected] | |
| with: | |
| webhook: ${{ secrets.slack_webhook_url }} | |
| webhook-type: webhook-trigger | |
| payload: | | |
| status: "success" | |
| message: "Phrases Updated Successfully\n Wait for Netlify to deploy the changes before testing the new phrases." | |
| workflow_url: "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" | |
| - name: Notify Slack on success (no changes) | |
| if: success() && steps.fetch_phrases.outputs.phrases_updated == 'false' | |
| uses: slackapi/[email protected] | |
| with: | |
| webhook: ${{ secrets.slack_webhook_url }} | |
| webhook-type: webhook-trigger | |
| payload: | | |
| status: "no_changes" | |
| message: "Phrases Workflow Completed\nNo phrase changes detected in Google Sheets. Production is already up to date." | |
| workflow_url: "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" | |
| - name: Notify Slack on failure | |
| if: failure() | |
| uses: slackapi/[email protected] | |
| with: | |
| webhook: ${{ secrets.slack_webhook_url }} | |
| webhook-type: webhook-trigger | |
| payload: | | |
| status: "failure" | |
| message: "❌ Phrases Update Failed\nThe international phrases workflow encountered an error. Phrases were NOT updated." | |
| workflow_url: "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" |