diff --git a/Dockerfile b/Dockerfile index 8b1cb24..df71fc2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM crowdin/cli:3.6.5 +FROM crowdin/cli:3.7.0 RUN apk --no-cache add curl git jq gnupg; diff --git a/README.md b/README.md index f6f925f..2fcf137 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,7 @@ jobs: uses: actions/checkout@v2 - name: crowdin action - uses: crowdin/github-action@1.3.3 + uses: crowdin/github-action@1.4.0 with: upload_translations: true download_translations: true @@ -90,6 +90,17 @@ In case you don’t want to download translations from Crowdin (`download_transl # If not specified default repository branch will be used. pull_request_base_branch_name: not_default_branch + # branch options + add_crowdin_branch: branch_name + # Title as it appears to translators + new_branch_title: 'development / main' + # Defines branch name and path in resulting translations bundle + new_branch_export_pattern: '/translations/%two_letters_code%/%original_file_name%' + # [LOW, NORMAL, HIGH] + new_branch_priority: 'HIGH' + + delete_crowdin_branch: branch_name + # global options # This is the name of the top-level directory that Crowdin will use for files. diff --git a/action.yml b/action.yml index 15e201e..739c11d 100644 --- a/action.yml +++ b/action.yml @@ -92,6 +92,24 @@ inputs: default: '' required: false + # branch options + add_crowdin_branch: + description: 'Option to create specified version branch in your Crowdin project' + required: false + new_branch_title: + description: 'Use to provide more details for translators. Title is available in UI only' + required: false + new_branch_export_pattern: + description: 'Branch export pattern. Defines branch name and path in resulting translations bundle' + required: false + new_branch_priority: + description: 'Defines priority level for each branch [LOW, NORMAL, HIGH]' + required: false + + delete_crowdin_branch: + description: 'Option to remove specified version branch in your Crowdin project' + required: false + # global options crowdin_branch_name: description: 'Option to upload or download files to the specified version branch in your Crowdin project' diff --git a/entrypoint.sh b/entrypoint.sh index 95f181c..bd83e56 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -179,6 +179,16 @@ setup_commit_signing() { rm private.key } +get_branch_available_options() { + for OPTION in "$@" ; do + if echo "$OPTION" | egrep -vq "^(--dryrun|--branch|--source|--translation)"; then + AVAILABLE_OPTIONS="${AVAILABLE_OPTIONS} ${OPTION}" + fi + done + + echo "$AVAILABLE_OPTIONS" +} + echo "STARTING CROWDIN ACTION" view_debug_output @@ -234,6 +244,19 @@ if [ -n "$INPUT_TRANSLATION" ]; then fi #EXECUTE COMMANDS + +if [ -n "$INPUT_ADD_CROWDIN_BRANCH" ]; then + NEW_BRANCH_OPTIONS=$( get_branch_available_options "$@" ) + + if [ -n "$INPUT_NEW_BRANCH_PRIORITY" ]; then + NEW_BRANCH_OPTIONS="${NEW_BRANCH_OPTIONS} --priority=${INPUT_NEW_BRANCH_PRIORITY}" + fi + + echo "CREATING BRANCH $INPUT_ADD_CROWDIN_BRANCH" + + crowdin branch add $INPUT_ADD_CROWDIN_BRANCH $NEW_BRANCH_OPTIONS --title="${INPUT_NEW_BRANCH_TITLE}" --export-pattern="${INPUT_NEW_BRANCH_EXPORT_PATTERN}" +fi + if [ "$INPUT_UPLOAD_SOURCES" = true ]; then upload_sources "$@" fi @@ -258,3 +281,9 @@ if [ "$INPUT_DOWNLOAD_TRANSLATIONS" = true ]; then push_to_branch fi fi + +if [ -n "$INPUT_DELETE_CROWDIN_BRANCH" ]; then + echo "REMOVING BRANCH $INPUT_DELETE_CROWDIN_BRANCH" + + crowdin branch delete $INPUT_DELETE_CROWDIN_BRANCH $( get_branch_available_options "$@" ) +fi