Sync Blog #1269
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: Sync Blog | |
on: | |
schedule: | |
- cron: "30 4 * * *" | |
- cron: "0 11 * * *" | |
workflow_dispatch: | |
jobs: | |
sync_blog: | |
runs-on: ubuntu-latest | |
if: github.repository == 'emqx/blog' | |
steps: | |
- name: Set git | |
run: | | |
git config --global user.name "emqx-ci-robot" | |
git config --global user.email "[email protected]" | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Sync blogs | |
id: sync_blog | |
run: | | |
set -x | |
branch=$(date +%Y-%m-%d-%H-%M-%S) | |
echo "::set-output name=branch::$branch" | |
git checkout -b $branch | |
python3 .ci/sync_blog.py $(pwd) | |
python3 .ci/generate_readme.py $(pwd) | |
git status | |
if [ -z "$(git status --short)" ]; then | |
echo "No changes to push" | |
echo "::set-output name=changed::0" | |
else | |
git add . | |
git commit -m "sync blog" | |
git push origin $branch | |
echo "::set-output name=changed::1" | |
fi | |
- name: Pull request | |
uses: repo-sync/pull-request@v2 | |
if: steps.sync_blog.outputs.changed == 1 | |
with: | |
source_branch: ${{ steps.sync_blog.outputs.branch }} | |
destination_branch: main | |
github_token: ${{ secrets.CI_GIT_TOKEN }} | |
pr_title: "sync blogs" | |
pr_reviewer: "CrazyWisdom" |