From 8af0691d777041587ee4a00110317c87ab0c200f 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/6] 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..429dd5d77 --- /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 update 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: ${{ github.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 41f5135dac65eb653e5390b8022c7232e20ac522 Mon Sep 17 00:00:00 2001 From: koy Date: Mon, 10 Jun 2024 19:41:51 +0800 Subject: [PATCH 2/6] update: test ci --- .github/workflows/{emoji.yml => update-emoji.yml} | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) rename .github/workflows/{emoji.yml => update-emoji.yml} (93%) diff --git a/.github/workflows/emoji.yml b/.github/workflows/update-emoji.yml similarity index 93% rename from .github/workflows/emoji.yml rename to .github/workflows/update-emoji.yml index 429dd5d77..8411b016b 100644 --- a/.github/workflows/emoji.yml +++ b/.github/workflows/update-emoji.yml @@ -11,6 +11,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + ref: mock-emoji-late - uses: actions/setup-node@v4 with: @@ -36,6 +37,6 @@ jobs: - 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 + gh pr create --title 'chore: Sync emoji data with GitHub emoji API' --body 'Found updated github emojis need to sync.' --base mock-emoji-late --reviewer docsifyjs/reviewers env: GH_TOKEN: ${{ github.token }} From da248fd9886ae14b665cdcefd88849de9a8d1d59 Mon Sep 17 00:00:00 2001 From: koy Date: Mon, 10 Jun 2024 19:44:06 +0800 Subject: [PATCH 3/6] update: test ci --- .github/workflows/update-emoji.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/update-emoji.yml b/.github/workflows/update-emoji.yml index 8411b016b..8a2a643d4 100644 --- a/.github/workflows/update-emoji.yml +++ b/.github/workflows/update-emoji.yml @@ -11,7 +11,8 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - ref: mock-emoji-late + with: + ref: mock-emoji-late - uses: actions/setup-node@v4 with: From fa1b0d12de568ae984d8112b2d887b10d51ee704 Mon Sep 17 00:00:00 2001 From: Luffy <52o@qq52o.cn> Date: Mon, 10 Jun 2024 20:08:14 +0800 Subject: [PATCH 4/6] Update .github/workflows/update-emoji.yml --- .github/workflows/update-emoji.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/update-emoji.yml b/.github/workflows/update-emoji.yml index 8a2a643d4..abbc05481 100644 --- a/.github/workflows/update-emoji.yml +++ b/.github/workflows/update-emoji.yml @@ -40,4 +40,4 @@ jobs: run: | gh pr create --title 'chore: Sync emoji data with GitHub emoji API' --body 'Found updated github emojis need to sync.' --base mock-emoji-late --reviewer docsifyjs/reviewers env: - GH_TOKEN: ${{ github.token }} + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} From 0df0f836069006a60e2c45bb0e0cb00d1429adbb Mon Sep 17 00:00:00 2001 From: Luffy <52o@qq52o.cn> Date: Mon, 10 Jun 2024 20:29:54 +0800 Subject: [PATCH 5/6] Update .github/workflows/update-emoji.yml --- .github/workflows/update-emoji.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/update-emoji.yml b/.github/workflows/update-emoji.yml index abbc05481..03ae56f0a 100644 --- a/.github/workflows/update-emoji.yml +++ b/.github/workflows/update-emoji.yml @@ -40,4 +40,4 @@ jobs: run: | gh pr create --title 'chore: Sync emoji data with GitHub emoji API' --body 'Found updated github emojis need to sync.' --base mock-emoji-late --reviewer docsifyjs/reviewers env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GH_TOKEN: ${{ secrets.READ_TEAM_TOKEN }} From c3ed19531bd35e6938c9434253915df3b09ade2a Mon Sep 17 00:00:00 2001 From: Luffy <52o@qq52o.cn> Date: Mon, 10 Jun 2024 21:24:03 +0800 Subject: [PATCH 6/6] Update update-emoji.yml --- .github/workflows/update-emoji.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/update-emoji.yml b/.github/workflows/update-emoji.yml index 03ae56f0a..e2afc1e8a 100644 --- a/.github/workflows/update-emoji.yml +++ b/.github/workflows/update-emoji.yml @@ -39,5 +39,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 mock-emoji-late --reviewer docsifyjs/reviewers + continue-on-error: true env: GH_TOKEN: ${{ secrets.READ_TEAM_TOKEN }}