fix: add post migration to trigger sync resources - WPB-14794 (#2240) #1206
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Crowdin Action | |
on: | |
push: | |
branches: [ develop ] | |
# Allows you to run this workflow manually from the Actions tab | |
workflow_dispatch: | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
jobs: | |
synchronize-with-crowdin: | |
runs-on: ubuntu-22.04 | |
container: swift:5.10.1 | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Crowdin action | |
uses: crowdin/github-action@v2 | |
with: | |
# For more info: https://github.com/crowdin/github-action/blob/master/action.yml | |
project_id: ${{ secrets.CROWDIN_PROJECT_ID }} | |
token: ${{ secrets.CROWDIN_API_TOKEN }} | |
config: crowdin.yml | |
upload_sources: true | |
download_translations: true | |
upload_translations: false | |
create_pull_request: false | |
push_translations: true | |
localization_branch_name: chore/update-localization | |
commit_message: "chore: Update localization" | |
github_user_name: "zenkins" | |
github_user_email: "iosx@wire.com" | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Trim unused localizations from string catalogs and create PR | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
BASE_BRANCH=${GITHUB_REF#refs/heads/} | |
HEAD_BRANCH="chore/update-localization" | |
TITLE="chore: Update localization - no ticket" | |
BODY="This PR pulls in the latest localization translations from Crowdin." | |
git config --global --add safe.directory "$GITHUB_WORKSPACE" | |
find . -name "*.xcstrings" | tee string-catalogs.txt | |
xargs swift run --package-path ./scripts TrimStringCatalogs < string-catalogs.txt | |
xargs git add < string-catalogs.txt | |
# abort if there are no changes after trimming | |
if git diff --quiet && git diff --cached --quiet; then | |
echo "No changes to commit." | |
exit 0 | |
fi | |
# commit and push the changes | |
git commit --no-verify -m "chore: trim string catalogs" | |
git push --no-verify origin "$HEAD_BRANCH" | |
# abort if there no changes to be merged | |
if git diff --quiet "origin/$BASE_BRANCH"; then | |
echo "No changes compared to the base branch, aborting." | |
exit 0 | |
fi | |
# abort if the pr already exists | |
apt update && apt install -y gh | |
PR_EXISTS=$(gh pr list --base "$BASE_BRANCH" --head "$HEAD_BRANCH" --state open --json number --jq '.[0].number') | |
if [ -n "$PR_EXISTS" ]; then | |
echo "A PR already exists, aborting." | |
exit 0 | |
fi | |
gh pr create --fill \ | |
--base "$BASE_BRANCH" \ | |
--head "$HEAD_BRANCH" \ | |
--title "$TITLE" \ | |
--body "$BODY" \ |