-
Notifications
You must be signed in to change notification settings - Fork 66
52 lines (47 loc) · 1.4 KB
/
sync_blog.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
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"