|
| 1 | +name: WIP Pull Localization from Google Sheets |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: {} |
| 5 | + |
| 6 | +env: |
| 7 | + KEY_JSON_PATH: 'SecretCache/UnityLocalizationExtension/service-account-key.json' |
| 8 | + BASE_BRANCH: ${{ github.ref_name }} |
| 9 | + HEAD_BRANCH: ${{ github.ref_name }}-update |
| 10 | + |
| 11 | +jobs: |
| 12 | + pull-localization-tables: |
| 13 | + name: Pull Localization Tables |
| 14 | + runs-on: ubuntu-latest |
| 15 | + steps: |
| 16 | + - uses: actions/checkout@v3 |
| 17 | + with: |
| 18 | + lfs: true |
| 19 | + |
| 20 | + - name: Generate Key |
| 21 | + shell: bash |
| 22 | + run: | |
| 23 | + mkdir -p $(dirname "${{ env.KEY_JSON_PATH }}") |
| 24 | + echo "${{ secrets.GOOGLE_SERVICE_ACCOUNT_KEY_JSON_BASE64 }}" | base64 --decode > "${{ env.KEY_JSON_PATH }}" |
| 25 | +
|
| 26 | + - name: Execute PullAllLocalizationTables |
| 27 | + uses: game-ci/unity-builder@v2 |
| 28 | + env: |
| 29 | + UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }} |
| 30 | + with: |
| 31 | + projectPath: ./ |
| 32 | + unityVersion: 2021.3.6f1 |
| 33 | + targetPlatform: Android |
| 34 | + buildMethod: Tsgcpp.Localization.Extension.Example.Editor.ExampleLocalizationSynchronizationMenu.PullAllLocalizationTablesFromTempKeyJson |
| 35 | + |
| 36 | + - name: Delete Key |
| 37 | + if: always() |
| 38 | + run: | |
| 39 | + rm -f "${{ env.KEY_JSON_PATH }}" |
| 40 | +
|
| 41 | + - name: Git Commit String Tables |
| 42 | + id: commit |
| 43 | + shell: bash |
| 44 | + run: | |
| 45 | + set -eux |
| 46 | +
|
| 47 | + git checkout -b ${{ env.HEAD_BRANCH }} |
| 48 | +
|
| 49 | + git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com" |
| 50 | + git config --local user.name "github-actions[bot]" |
| 51 | +
|
| 52 | + git reset |
| 53 | + git add --update "Assets/Example/StringTableCollection" |
| 54 | + DIFF_COUNT=$(git diff --staged --name-only | wc -l) |
| 55 | +
|
| 56 | + if [ "${DIFF_COUNT}" -le 0 ] |
| 57 | + then |
| 58 | + echo "::notice::Skipped the commit becuase no differences were found." |
| 59 | + exit 0 |
| 60 | + fi |
| 61 | +
|
| 62 | + DATE=$(date '+%Y/%m/%d %H:%M') |
| 63 | + TITLE="Update StringCollectionTable (${DATE})" |
| 64 | +
|
| 65 | + git commit -m "${TITLE}" |
| 66 | +
|
| 67 | + echo "::set-output name=has_diff::true" |
| 68 | + echo "::set-output name=title::${TITLE}" |
| 69 | +
|
| 70 | + - name: Git Push ans PullRequest |
| 71 | + if: steps.commit.outputs.has_diff == 'true' |
| 72 | + shell: bash |
| 73 | + run: | |
| 74 | + REMOTE_SHA=$(git ls-remote --heads origin ${{ env.HEAD_BRANCH }}) |
| 75 | + if [ -n "${REMOTE_SHA}" ] |
| 76 | + then |
| 77 | + git push origin :${{ env.HEAD_BRANCH }} |
| 78 | + echo "::notice::The remote branch (ref_name: ${{ env.HEAD_BRANCH }}, sha: ${REMOTE_SHA})" |
| 79 | + fi |
| 80 | +
|
| 81 | + git push origin ${{ env.HEAD_BRANCH }} |
| 82 | +
|
| 83 | + sleep 2 |
| 84 | +
|
| 85 | + PR_URL=$(gh pr create \ |
| 86 | + --base "${{ env.BASE_BRANCH }}" \ |
| 87 | + --head "${{ env.HEAD_BRANCH }}" \ |
| 88 | + --title "${{ steps.commit.outputs.title }}" \ |
| 89 | + --body "" \ |
| 90 | + ) |
| 91 | +
|
| 92 | + echo "::notice::${PR_URL} was issued." |
| 93 | +
|
| 94 | + env: |
| 95 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 96 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 97 | + |
| 98 | + - name: Notice |
| 99 | + run: | |
| 100 | + echo "This is a notification phase" |
0 commit comments