Skip to content

Ability to run arbitrary scripts before a commit is made #178

Description

@quantizor

Is your feature request related to a problem? Please describe.
I'm working on integrating CrowdIn with a project using "changesets". I'd like to run a script that adds a file to be committed alongside the translations.

Describe the solution you'd like
A before_commit_script option in the action for some arbitrary bash code to be run before files are committed to the localization branch.

Describe alternatives you've considered
I have a different github workflow rigged up but it would be nice to not need an additional workflow.

Activity

  1. andrii-bodnar commented on Jun 22, 2023

    @andrii-bodnar
    Member

    Hi @probablyup, thanks for the request!

    Currently, you can disable pull request creation by the Action and use a separate Action for this after making the necessary changes:

    name: Crowdin Action
    
    on:
      push:
        branches: [ main ]
    
    jobs:
      synchronize-with-crowdin:
        runs-on: ubuntu-latest
    
        steps:
          - name: Checkout
            uses: actions/checkout@v3
    
          - name: crowdin action
            uses: crowdin/github-action@v1
            with:
              upload_sources: true
              upload_translations: true
              download_translations: true
              push_translations: false             # Do not commit & push changes
              create_pull_request: false         # Do not create a PR
            env:
              GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
              CROWDIN_PROJECT_ID: ${{ secrets.CROWDIN_PROJECT_ID }}
              CROWDIN_PERSONAL_TOKEN: ${{ secrets.CROWDIN_PERSONAL_TOKEN }}
    
          - name: Custom script
            run: ./script.sh
    
          - name: Create Pull Request
            uses: peter-evans/create-pull-request@v5
            with:
              commit-message: 'New Crowdin translations'
              title: 'New Crowdin Translations'
              body: 'New Crowdin translations by [Crowdin GH Action](https://github.com/crowdin/github-action)'
              branch: 'feat/l10n-crowdin-translations'

    Visit the Create Pull Request GH Action page to see all the available options.

    P.S. I didn't test this example, but the workflow should look like the above.

  2. renchap commented on Jul 18, 2023

    @renchap

    We are looking for a similar option, but in our case to run linting & normalisation scripts before the commit.

  3. andrii-bodnar commented on Jul 20, 2023

    @andrii-bodnar
    Member

    Hi @renchap, I just saw your solution and it looks pretty good 🙂

  4. renchap commented on Jul 20, 2023

    @renchap

    Hi @renchap, I just saw your solution and it looks pretty good 🙂

    Yes, and I understand why it would be hard to do in the action, because your command will be ran from the container, where you most probably dont have the dependencies you need.

    Related to this, I was not expecting the files generated by the action to be owned by root:root, you may want to have their permissions fixed before the action finishes.

  5. locked and limited conversation to collaborators on Jul 24, 2023
  6. converted this issue into a discussion #181 on Jul 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions