github-action icon indicating copy to clipboard operation
github-action copied to clipboard

Add `download_sources` option

Open sazarubin opened this issue 4 years ago • 4 comments

Problem I'm trying to implement workflow, where Crowdin and not the repo is the source of truth both for source strings and translations. It would go like this:

  1. Developer adds new string using Crowdin UI
  2. Crowdin GitHub action in the translations repo is triggered by cron, adds a new string to repo, opens PR
  3. PR is auto-merged to main branch
  4. Sources from the main branch are used to build TypeScript typing packages and pushed to our registry

But when I add a new string to a source file using Crowdin UI and then GitHub action from (2) triggers, it removes new string from Crowdin instead of adding it to the repo. I couldn't find an option to download source files from Crowdin, but it exists in Crowdin CLI.

Solution I'd like It would be convenient and also seems pretty logical and easy to add a download_sources option symmetric to upload_sources. The default value would be false, so it won't surprise or break existing integrations.

I'm not sure if this option would be useful for most Crowdin Action users, but it sure won't harm anyone being off by default, nor would it add much complexity to the action code.

Alternatives I've considered I could change workflow, but it would harm developer experience, because when developer adds a new string by commiting to repo, he or she would also need to go to UI to add context, screenshot, translations for his/her native languages and so on. So, it seems to me that starting the process from Crowdin UI would be more straightforward. I also could use Crowdin CLI directly, but I like using this action 😃

I'm glad to send PR if that helps in any way.

sazarubin avatar Jul 02 '21 14:07 sazarubin

Hi there! Thank you for the details, checking them

Olena1234 avatar Jul 03 '21 05:07 Olena1234

I got it working, but it's not trivial to align commit & push with download_translations behaviour. Currently my version relies on push_translations option to push sources, which isn't obvious at all.

I have some suggestions below on how to make this more obvious, but I certainly underestimated the complexity of such change.

Commit and push options are currently documented and used as download translations options, so I see two ways of setting up download_sources commit and push.

  • Option 1: Create separate commits for sources and translations and use separate options for them: commit_sources, sources_commit_message, commit_translations and translations_commit_message (an alias of commit_message).
  • Option 2: Create a single commit for sources and translations with commit_message and extract commit and push into separate section.

In any case, action would benefit from aliasing push_translations as push and calling push once in the end of the action.

Also, there is a catch in option 1. If I disable commit_sources, but enable commit_translations, I expect the sources not to be commited. To achieve that, we need to stash everything before commiting translations and popping the stash afterwards. If we take it a step further, I would expect that commit_sources also commit nothing but sources, so we need stash && download && stash pop there too.

I hope Crowdin developers have more insight into which alternative would benefit their users more, but after some thought I consider using Crowdin CLI directly because our workflow seem to be too specific for general-purpose action.

sazarubin avatar Jul 05 '21 11:07 sazarubin

Hi there! Glad to hear that you got it working, it looks to us that your current realization is pretty simple and flexible. Regarding your options, the more new parameters would be added, the more complex the GitHub action would be. You may also specify download_sources with commit_message as a one job and download_translations with the different commit_message as another job. In case you would specify download_sources and download_translations in one job, then everything could go to one commit with the common commit_message

Olena1234 avatar Jul 05 '21 13:07 Olena1234

Hi @sazarubin!

Is the provided solution above is clear for you? This solution will be flexible and simple

In any case, we can discuss this in more detail :slightly_smiling_face:

andrii-bodnar avatar Jul 15 '21 13:07 andrii-bodnar