-
Notifications
You must be signed in to change notification settings - Fork 4
84 lines (73 loc) · 2.92 KB
/
sync_docs.yml
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
name: Sync Docs
on:
schedule:
- cron: '0 */3 * * *'
workflow_dispatch:
jobs:
sync:
runs-on: ubuntu-latest
steps:
- name: Checkout the Infinity repository
# https://github.com/actions/checkout/blob/v3/README.md
uses: actions/checkout@v3
with:
repository: infiniflow/infinity
# Relative path under $GITHUB_WORKSPACE to place the repository
path: source
- name: Checkout Infinity docs repo
uses: actions/checkout@v3
with:
repository: infiniflow/infinity-docs
path: target
- name: Install Dependences
# Install lightweight command-line JSON processor
run: sudo apt-get install -y jq
- name: Set Env
run: |
echo "INFINITY_MAIN=${GITHUB_WORKSPACE}/source" >> $GITHUB_ENV
echo "INFINITY_WEBSITE=${GITHUB_WORKSPACE}/target" >> $GITHUB_ENV
- name: Export Env
run: |
export INFINITY_MAIN=${{ env.INFINITY_MAIN }}
export INFINITY_WEBSITE=${{ env.INFINITY_WEBSITE }}
- name: Sync and stage changes
run: |
cd $INFINITY_MAIN && git fetch --tags
cd $INFINITY_WEBSITE/website && ./sync_docs.sh
- name: Create a Pull Request
id: create-pr
# https://github.com/peter-evans/create-pull-request
uses: peter-evans/create-pull-request@v6
with:
token: ${{ secrets.CURATOR_PAT }}
path: target
commit-message: Synchronize documentation.
committer: Infinity Curator <[email protected]>
author: Infinity Curator <[email protected]>
signoff: false
base: main
branch: sync-documentation
delete-branch: true
draft: false
title: '[Cron] Sync and update documentation'
body: 'Auto-generated and will be automatically merged.'
labels: |
automation
- name: Check outputs
run: |
echo "Pull Request Number - ${{ steps.create-pr.outputs.pull-request-number }}"
echo "Pull Request Operation - ${{ steps.create-pr.outputs.pull-request-operation }}"
- name: Enable auto-merge on the pull request
if: steps.create-pr.outputs.pull-request-operation == 'created'
uses: peter-evans/enable-pull-request-automerge@v1
with:
token: ${{ secrets.CURATOR_PAT }}
pull-request-number: ${{ steps.create-pr.outputs.pull-request-number }}
merge-method: squash
- name: Auto approve the pull request
if: steps.create-pr.outputs.pull-request-operation == 'created'
uses: juliangruber/[email protected]
with:
# Use Action Bot to approve the pull request because one cannot approve his own.
github-token: ${{ secrets.GITHUB_TOKEN }}
number: ${{ steps.create-pr.outputs.pull-request-number }}