From dfefba84496bb1d6ca538ba029f2e6d027ac8af2 Mon Sep 17 00:00:00 2001 From: lifehackerhansol Date: Wed, 24 Apr 2024 00:23:30 -0700 Subject: [PATCH 1/2] workflow: add automation of uploading source text to Crowdin This will push to Crowdin if a push to main branch was successful. This allows automation of syncing source text, making it less of a hassle to synchronize all translations. --- .github/workflows/crowdin-upload.yml | 34 ++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 .github/workflows/crowdin-upload.yml diff --git a/.github/workflows/crowdin-upload.yml b/.github/workflows/crowdin-upload.yml new file mode 100644 index 0000000000000..9251406760f80 --- /dev/null +++ b/.github/workflows/crowdin-upload.yml @@ -0,0 +1,34 @@ +name: Upload source files to Crowdin + +on: + push: + branches: [ main ] + paths: + - '_pages/en_US/**.txt' + workflow_dispatch: + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + with: + persist-credentials: false + + - uses: ruby/setup-ruby@v1 + with: + ruby-version: '3.2' + bundler-cache: true + + # Build the site using Jekyll + # No point pushing to Crowdin if the site build is failing + - name: Test site build via Jekyll + run: JEKYLL_ENV=production bundle exec jekyll build + + - name: Push to Crowdin + uses: crowdin/github-action@v2 + with: + upload_sources: true + env: + CROWDIN_TOKEN: ${{ secrets.CROWDIN_TOKEN }} From 95fa8fab9b9ee807d4b275b39dded90196529567 Mon Sep 17 00:00:00 2001 From: lifehackerhansol Date: Wed, 24 Apr 2024 00:31:53 -0700 Subject: [PATCH 2/2] workflow: add automation of syncing translations from Crowdin This will poll translations from Crowdin bi-weekly, test a build to make sure that the site will compile, and then push to the main branch. This saves the effort of manually syncing translations. --- .github/workflows/crowdin-commit.yml | 57 ++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 .github/workflows/crowdin-commit.yml diff --git a/.github/workflows/crowdin-commit.yml b/.github/workflows/crowdin-commit.yml new file mode 100644 index 0000000000000..cd2c44d3a542d --- /dev/null +++ b/.github/workflows/crowdin-commit.yml @@ -0,0 +1,57 @@ +name: Import translations from Crowdin + +on: + schedule: + - cron: "0 0 1,15 * *" + workflow_dispatch: + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + with: + persist-credentials: false + + - uses: ruby/setup-ruby@v1 + with: + ruby-version: '3.2' + bundler-cache: true + + - uses: actions/setup-node@v4 + + - name: Setup Crowdin CLI + run: | + npm i -g @crowdin/cli + + - name: Pull from Crowdin + run: | + CROWDIN_TOKEN=${{ secrets.CROWDIN_TOKEN }} ./crowdin-pull.sh + + - name: Pull origin + run: git pull origin main --ff-only # Pull origin in case a commit has been done while updating + + # Build the site using Jekyll + # This makes sure that the site actually builds before pushing to Crowdin + - name: Test site build via Jekyll + run: JEKYLL_ENV=production bundle exec jekyll build + + - name: Push changes + run: | + git config user.email "flamekat54@aol.com" + git config user.name "TWLBot" + + echo "machine github.com" > "$HOME/.netrc" + echo " login TWLBot" >> "$HOME/.netrc" + echo " password ${{ secrets.TWLBOT_TOKEN }}" >> "$HOME/.netrc" + + echo "machine api.github.com" >> "$HOME/.netrc" + echo " login TWLBot" >> "$HOME/.netrc" + echo " password ${{ secrets.TWLBOT_TOKEN }}" >> "$HOME/.netrc" + + git checkout main + git stage . + if git commit -m "Automatic translation import"; then + git push origin main + fi