Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add option for add and delete branch in crowdin and update cli version #91

Merged
merged 1 commit into from
Sep 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -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;

Expand Down
13 changes: 12 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down
18 changes: 18 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
29 changes: 29 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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