Options for making Netlify deploy previews with translations

Following up on this:

@ByteHamster, I’d like to get your advice/opinion.

Netlify’s Deply Preview integration is so simple, that it’s just a matter of clicking some buttons - but this also means there’s no GitHub action that we can adjust. I see a few options to still get Netlify Deploy previews for new languages:

  • Set up a GitHub action that we can manually trigger, for which case you have to select a branch. The branch you select would be the one of the PR that adds a language to the config file. The trigger checks in 1] the the config file of the PR from the selected branch (where the extra languages are added), 2] all other files from the master branch (which has the relevant site files), and 3] the translation files from the translations branch. From this mix, it creates the relevant localised files. It them commits them to the master branch. We then can trigger a re-test for the PR, and Netlify can build the deploy preview with the language added in the PR.
    • Making it slightly more advanced, we could automate this - and have this action run automatically when the config file is changed in a PR. We build in an extra step in the beginning: If the list of languages changed in that PR compared to master, the rest executed. If the list is not changed, the action exits with success without doing anything. This would allow anyone to create files in the _i18n folder by creating a PR that adds a language, but that’s a limited risk (as we manually pull translations from Weblate, and this action won’t make the translations available on the live website.
  • Kind of the same idea as above, but instead of committing the localised files to master, a new PR (PR2) is opened automatically with the same mix mentioned above, triggering a deploy preview being built by Netlify that contains both the updated config as well as the localised files, therefore generating a usable deploy preview.
    • Alternatively, instead of creating a new PR, create a new branch and trigger a branch build via a Netlify build hook - not sure this would work.
  • Kind of the same idea as above, but instead of committing the localised files directly to master, just commit to the PR branch. That should trigger an updated Netlify deploy, so it can be reviewed. The PR can then be merged including the localised files (which is normally the task of the translation-updates-to-main-repo action). However, this PR might then be outdated already when it is merged, as by the time the translations have been reviewed, corrections will be waiting in Weblate (or even in the translations branch).

Hmm, the ideas all sound like quite a bit of work. How about just publishing the new language normally but not adding it to the menu until it is reviewed?

Yes, they seemed quite a bit of work. Since you’re fine with pushing translations to the main branch (without having them generated in the live site), I updated the workflow so we can manually localised files for specific languages. That was indeed the easiest solution :slight_smile:

However, I now realise that the action cannot commit to the protected main branch:

remote: error: GH006: Protected branch update failed for refs/heads/master.        
remote: error: 2 of 2 required status checks are expected.        
To https://github.com/AntennaPod/antennapod.github.io
 ! [remote rejected] master -> master (protected branch hook declined)
error: failed to push some refs to 'https://github.com/AntennaPod/antennapod.github.io'
Error: Process completed with exit code 1.

Having an action push to a protected branch seems not supported out of the box (though there are some workarounds):

A GitHub Action seems to exist to write to protected branches:

Not sure why that would (suddenly) work, though

Ok, we decided to lift the write protection. So the workflow now works fine.

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.