From 7e6404cb67dc1f1212e9767888857ea25e72bb82 Mon Sep 17 00:00:00 2001 From: Paul Fitzpatrick Date: Mon, 23 Jan 2023 16:27:26 -0500 Subject: [PATCH 1/2] introduce a workflow for keeping translation keys fresh --- .github/workflows/translation_keys.yml | 60 ++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 .github/workflows/translation_keys.yml diff --git a/.github/workflows/translation_keys.yml b/.github/workflows/translation_keys.yml new file mode 100644 index 00000000..d490e254 --- /dev/null +++ b/.github/workflows/translation_keys.yml @@ -0,0 +1,60 @@ +name: Translation keys + +on: + push: + branches: [ main ] + workflow_dispatch: + +permissions: + pull-requests: write + contents: write + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 # Let's get all the branches + + - name: Use Node.js + uses: actions/setup-node@v1 + with: + node-version: 16 + + - name: Install Node.js packages + run: yarn install + + - name: Build code + run: yarn run build:prod + + - name: Scan for keys + id: scan-keys + run: | + git checkout -b translation-keys + yarn run generate:translation + git status --porcelain + if [[ $(git status --porcelain | wc -l) -eq "0" ]]; then + echo "No changes" + echo "CHANGED=false" >> $GITHUB_ENV + else + echo "Changes detected" + echo "CHANGED=true" >> $GITHUB_ENV + fi + + - name: setup git config + run: | + git config user.name "Paul's Grist Bot" + git config user.email "" + + - name: Prepare PR + if: env.CHANGED == 'true' + run: | + git commit -m "automated update to translation keys" -a + git push --set-upstream origin HEAD:translation-keys -f + num=$(gh pr list --search "automated update to translation keys" --json number -q ".[].number") + if [[ "$num" = "" ]]; then + gh pr create --fill + fi + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From 6476fc30b75275907abf793a808e0a0c216bd1e7 Mon Sep 17 00:00:00 2001 From: Paul Fitzpatrick Date: Tue, 24 Jan 2023 09:15:14 -0500 Subject: [PATCH 2/2] use node 14, and only run on gristlabs --- .github/workflows/translation_keys.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/translation_keys.yml b/.github/workflows/translation_keys.yml index d490e254..39bc35c7 100644 --- a/.github/workflows/translation_keys.yml +++ b/.github/workflows/translation_keys.yml @@ -11,6 +11,7 @@ permissions: jobs: build: + if: github.repository_owner == 'gristlabs' runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 @@ -20,7 +21,7 @@ jobs: - name: Use Node.js uses: actions/setup-node@v1 with: - node-version: 16 + node-version: 14 - name: Install Node.js packages run: yarn install