From abc749458635b25b0c570a1a20cf025330ad2d21 Mon Sep 17 00:00:00 2001 From: JimmFly Date: Wed, 11 Jan 2023 15:55:50 +0800 Subject: [PATCH] chore: test workflow --- .github/workflows/languages-download.yml | 89 ++++++++++++++++++++ .github/workflows/languages-download.yml.bak | 89 -------------------- .github/workflows/languages-sync.yml | 63 ++++++++++++++ .github/workflows/languages-sync.yml.bak | 63 -------------- 4 files changed, 152 insertions(+), 152 deletions(-) create mode 100644 .github/workflows/languages-download.yml delete mode 100644 .github/workflows/languages-download.yml.bak create mode 100644 .github/workflows/languages-sync.yml delete mode 100644 .github/workflows/languages-sync.yml.bak diff --git a/.github/workflows/languages-download.yml b/.github/workflows/languages-download.yml new file mode 100644 index 0000000000..a3f8469038 --- /dev/null +++ b/.github/workflows/languages-download.yml @@ -0,0 +1,89 @@ +name: Download Languages Resources + +on: + # schedule: + # - cron: "0 0 * * 5" # At 00:00(UTC) on Friday. + workflow_dispatch: + +# Cancels all previous workflow runs for pull requests that have not completed. +# See https://docs.github.com/en/actions/using-jobs/using-concurrency +concurrency: + # The concurrency group contains the workflow name and the branch name for + # pull requests or the commit hash for any other events. + group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }} + cancel-in-progress: true + +# This action need write permission to create pull requests +# See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#permissions +permissions: + contents: write + pull-requests: write + +jobs: + main: + strategy: + matrix: + node-version: [18] + os: [ubuntu-latest] + runs-on: ${{ matrix.os }} + + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Use pnpm + uses: pnpm/action-setup@v2 + with: + version: 7 + + - name: Use Node.js ${{ matrix.node-version }} + # https://github.com/actions/setup-node + uses: actions/setup-node@v3 + with: + node-version: ${{ matrix.node-version }} + cache: 'pnpm' + + - name: Install node modules + run: pnpm install + + - name: Sync Languages + working-directory: ./packages/i18n + run: pnpm run download-resources + env: + TOLGEE_API_KEY: ${{ secrets.TOLGEE_API_KEY }} + + - name: Push Branch + id: push + run: | + git add packages/i18n + # Do not proceed if there are no file differences + COMMIT=$(git rev-parse --verify origin/$TARGET_BRANCH || echo HEAD) + FILES_CHANGED=$(git diff-index --name-only --cached $COMMIT | wc -l) + if [[ "$FILES_CHANGED" = "0" ]]; then + echo "No file changes detected." + echo "::set-output name=skipPR::true" + exit 0 + fi + git config user.name 'github-actions[bot]' + git config user.email 'github-actions[bot]@users.noreply.github.com' + git commit --message 'feat(i18n): new translations' --no-verify + git remote set-url origin "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$GITHUB_REPOSITORY" + git push --force origin HEAD:$TARGET_BRANCH + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + TARGET_BRANCH: bot/new-translations + + - name: Get current date + id: date + run: echo "::set-output name=date::$(date +'%Y-%m-%d')" + + # see https://github.com/repo-sync/pull-request + - name: Create Pull Request + if: steps.push.outputs.skipPR != 'true' + uses: repo-sync/pull-request@v2 + with: + source_branch: 'bot/new-translations' # If blank, default: triggered branch + destination_branch: 'master' + pr_title: Update i18n (${{ steps.date.outputs.date }}) # Title of pull request + pr_label: 'data,bot' # Comma-separated list (no spaces) + github_token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/languages-download.yml.bak b/.github/workflows/languages-download.yml.bak deleted file mode 100644 index 570d3bd8ed..0000000000 --- a/.github/workflows/languages-download.yml.bak +++ /dev/null @@ -1,89 +0,0 @@ -name: Download Languages Resources - -on: - # schedule: - # - cron: "0 0 * * 5" # At 00:00(UTC) on Friday. - workflow_dispatch: - -# Cancels all previous workflow runs for pull requests that have not completed. -# See https://docs.github.com/en/actions/using-jobs/using-concurrency -concurrency: - # The concurrency group contains the workflow name and the branch name for - # pull requests or the commit hash for any other events. - group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }} - cancel-in-progress: true - -# This action need write permission to create pull requests -# See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#permissions -permissions: - contents: write - pull-requests: write - -jobs: - main: - strategy: - matrix: - node-version: [18] - os: [ubuntu-latest] - runs-on: ${{ matrix.os }} - - steps: - - name: Checkout - uses: actions/checkout@v3 - - - name: Use pnpm - uses: pnpm/action-setup@v2 - with: - version: 7 - - - name: Use Node.js ${{ matrix.node-version }} - # https://github.com/actions/setup-node - uses: actions/setup-node@v3 - with: - node-version: ${{ matrix.node-version }} - cache: 'pnpm' - - - name: Install node modules - run: pnpm install - - - name: Sync Languages - working-directory: ./packages/i18n - run: pnpm run download-resources - env: - TOLGEE_API_KEY: ${{ secrets.TOLGEE_API_KEY }} - - - name: Push Branch - id: push - run: | - git add packages/i18n - # Do not proceed if there are no file differences - COMMIT=$(git rev-parse --verify origin/$TARGET_BRANCH || echo HEAD) - FILES_CHANGED=$(git diff-index --name-only --cached $COMMIT | wc -l) - if [[ "$FILES_CHANGED" = "0" ]]; then - echo "No file changes detected." - echo "::set-output name=skipPR::true" - exit 0 - fi - git config user.name 'github-actions[bot]' - git config user.email 'github-actions[bot]@users.noreply.github.com' - git commit --message 'feat(i18n): new translations' --no-verify - git remote set-url origin "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$GITHUB_REPOSITORY" - git push --force origin HEAD:$TARGET_BRANCH - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - TARGET_BRANCH: bot/new-translations - - - name: Get current date - id: date - run: echo "::set-output name=date::$(date +'%Y-%m-%d')" - - # see https://github.com/repo-sync/pull-request - - name: Create Pull Request - if: steps.push.outputs.skipPR != 'true' - uses: repo-sync/pull-request@v2 - with: - source_branch: 'bot/new-translations' # If blank, default: triggered branch - destination_branch: "master" - pr_title: Update i18n (${{ steps.date.outputs.date }}) # Title of pull request - pr_label: 'data,bot' # Comma-separated list (no spaces) - github_token: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/languages-sync.yml b/.github/workflows/languages-sync.yml new file mode 100644 index 0000000000..50fe3dbec1 --- /dev/null +++ b/.github/workflows/languages-sync.yml @@ -0,0 +1,63 @@ +name: Languages Sync + +on: + # push: + # branches: [ "feat/sync-languages" ] + # paths: + # - 'packages/i18n/**' + # - '.github/workflows/languages-sync.yml' + # pull_request: + # branches: [ "feat/sync-languages" ] + # paths: + # - 'packages/i18n/**' + # - '.github/workflows/languages-sync.yml' + workflow_dispatch: + +# Cancels all previous workflow runs for pull requests that have not completed. +# See https://docs.github.com/en/actions/using-jobs/using-concurrency +concurrency: + # The concurrency group contains the workflow name and the branch name for + # pull requests or the commit hash for any other events. + group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }} + cancel-in-progress: true + +jobs: + main: + strategy: + matrix: + node-version: [18] + os: [ubuntu-latest] + runs-on: ${{ matrix.os }} + + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Use pnpm + uses: pnpm/action-setup@v2 + with: + version: 7 + + - name: Use Node.js ${{ matrix.node-version }} + # https://github.com/actions/setup-node + uses: actions/setup-node@v3 + with: + node-version: ${{ matrix.node-version }} + cache: 'pnpm' + + - name: Install node modules + run: pnpm install + + - name: Check Language Key + if: github.ref != 'feat/sync-languages' + working-directory: ./packages/i18n + run: pnpm run sync-languages:check + env: + TOLGEE_API_KEY: ${{ secrets.TOLGEE_API_KEY }} + + - name: Sync Languages + if: github.ref == 'feat/sync-languages' + working-directory: ./packages/i18n + run: pnpm run sync-languages + env: + TOLGEE_API_KEY: ${{ secrets.TOLGEE_API_KEY }} diff --git a/.github/workflows/languages-sync.yml.bak b/.github/workflows/languages-sync.yml.bak deleted file mode 100644 index 2a62fdd8ff..0000000000 --- a/.github/workflows/languages-sync.yml.bak +++ /dev/null @@ -1,63 +0,0 @@ -name: Languages Sync - -on: - # push: - # branches: [ "feat/sync-languages" ] - # paths: - # - 'packages/i18n/**' - # - '.github/workflows/languages-sync.yml' - # pull_request: - # branches: [ "feat/sync-languages" ] - # paths: - # - 'packages/i18n/**' - # - '.github/workflows/languages-sync.yml' - workflow_dispatch: - -# Cancels all previous workflow runs for pull requests that have not completed. -# See https://docs.github.com/en/actions/using-jobs/using-concurrency -concurrency: - # The concurrency group contains the workflow name and the branch name for - # pull requests or the commit hash for any other events. - group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }} - cancel-in-progress: true - -jobs: - main: - strategy: - matrix: - node-version: [18] - os: [ubuntu-latest] - runs-on: ${{ matrix.os }} - - steps: - - name: Checkout - uses: actions/checkout@v3 - - - name: Use pnpm - uses: pnpm/action-setup@v2 - with: - version: 7 - - - name: Use Node.js ${{ matrix.node-version }} - # https://github.com/actions/setup-node - uses: actions/setup-node@v3 - with: - node-version: ${{ matrix.node-version }} - cache: 'pnpm' - - - name: Install node modules - run: pnpm install - - - name: Check Language Key - if: github.ref != 'feat/sync-languages' - working-directory: ./packages/i18n - run: pnpm run sync-languages:check - env: - TOLGEE_API_KEY: ${{ secrets.TOLGEE_API_KEY }} - - - name: Sync Languages - if: github.ref == 'feat/sync-languages' - working-directory: ./packages/i18n - run: pnpm run sync-languages - env: - TOLGEE_API_KEY: ${{ secrets.TOLGEE_API_KEY }} \ No newline at end of file