From 25c49ef11bb390e16d78127e533adb82befcff06 Mon Sep 17 00:00:00 2001 From: sy-records <52o@qq52o.cn> Date: Mon, 10 Jun 2024 11:36:07 +0800 Subject: [PATCH 1/2] ci: Optimize CI processes --- .github/workflows/crowdin.yml | 1 + .github/workflows/emoji.yml | 41 +++++++++++++++++++++++ .github/workflows/update-emoji.yml | 53 ------------------------------ 3 files changed, 42 insertions(+), 53 deletions(-) create mode 100644 .github/workflows/emoji.yml delete mode 100644 .github/workflows/update-emoji.yml diff --git a/.github/workflows/crowdin.yml b/.github/workflows/crowdin.yml index 9c810f77d..262bb9af4 100644 --- a/.github/workflows/crowdin.yml +++ b/.github/workflows/crowdin.yml @@ -9,6 +9,7 @@ on: jobs: crowdin: + if: github.repository == 'docsifyjs/docsify' runs-on: ubuntu-latest steps: - name: Checkout diff --git a/.github/workflows/emoji.yml b/.github/workflows/emoji.yml new file mode 100644 index 000000000..d3932e275 --- /dev/null +++ b/.github/workflows/emoji.yml @@ -0,0 +1,41 @@ +name: Sync Emoji + +on: + schedule: + - cron: '0 2 * * *' + workflow_dispatch: + +jobs: + sync-emoji: + if: github.repository == 'docsifyjs/docsify' + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-node@v4 + with: + node-version: latest + cache: 'npm' + + - name: Install dependencies + run: npm ci --ignore-scripts + + - name: Run script to sync emoji data + run: npm run build:emoji + + - name: Commit + id: auto-commit-action + uses: stefanzweifel/git-auto-commit-action@v5 + with: + commit_message: 'chore: Sync emoji data with GitHub emoji API' + branch: sync-emoji + create_branch: true + file_pattern: 'src/core/render/emoji-data.js docs/emoji.md' + push_options: '--force' + + - name: Create Pull Request + if: ${{ steps.auto-commit-action.outputs.changes_detected == 'true' }} + run: | + gh pr create --title 'chore: Sync emoji data with GitHub emoji API' --body 'Found updated github emojis need to sync.' --base develop --reviewer docsifyjs/reviewers + env: + GH_TOKEN: ${{ secrets.READ_TEAM_TOKEN }} diff --git a/.github/workflows/update-emoji.yml b/.github/workflows/update-emoji.yml deleted file mode 100644 index 53b9857b2..000000000 --- a/.github/workflows/update-emoji.yml +++ /dev/null @@ -1,53 +0,0 @@ -name: Update Emoji - -on: - schedule: - - cron: '0 2 * * *' - workflow_dispatch: - -concurrency: - group: update-emoji-group - -jobs: - sync-emojis-from-github: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - - name: Setup Node.js v20 - uses: actions/setup-node@v4 - with: - node-version: 20 - cache: 'npm' - - - name: Install dependencies - run: npm ci --ignore-scripts - - - name: Fetch emojiData - run: npm run build:emoji - - - name: Check for changes - run: | - if git diff --quiet -- "src/core/render/emoji-data.js"; then - echo "No changes Found. Skipping PR creation." - else - echo "Changes detected in emoji-data.js. Creating PR." - - current_date=$(date +'%Y-%m-%d') - - branch_name="update-emoji-data-$current_date" - pr_title="update(emoji): Sync emoji data with GitHub emoji API [$current_date]" - git config --global user.email "actions@github.com" - git config --global user.name "GitHub Actions" - - git checkout -b $branch_name - git add src/core/render/emoji-data.js - git add docs/emoji.md - git commit -m "update(emoji): Sync emoji data with GitHub emoji API [$current_date]" - unique_branch_name=$branch_name-$(git log -1 --pretty=%h) - git checkout -b $unique_branch_name - git push origin $unique_branch_name - gh pr create --title "$pr_title" --body "Found updated github emojis need to sync, PTAL @docsifyjs/reviewers :robot:." --base develop - fi - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From d45235d5232f9a67d6a7f922f0f46430cfb4f016 Mon Sep 17 00:00:00 2001 From: Luffy <52o@qq52o.cn> Date: Mon, 10 Jun 2024 21:26:38 +0800 Subject: [PATCH 2/2] Update .github/workflows/emoji.yml --- .github/workflows/emoji.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/emoji.yml b/.github/workflows/emoji.yml index d3932e275..7e83197ef 100644 --- a/.github/workflows/emoji.yml +++ b/.github/workflows/emoji.yml @@ -37,5 +37,6 @@ jobs: if: ${{ steps.auto-commit-action.outputs.changes_detected == 'true' }} run: | gh pr create --title 'chore: Sync emoji data with GitHub emoji API' --body 'Found updated github emojis need to sync.' --base develop --reviewer docsifyjs/reviewers + continue-on-error: true env: GH_TOKEN: ${{ secrets.READ_TEAM_TOKEN }}