generated from gouef/github-lib-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaction.yml
66 lines (59 loc) · 1.79 KB
/
action.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
name: Github wiki sync repository action
description: Create / Generate / Update Github wiki based on your repository documentation
branding:
icon: book-open
color: green
inputs:
dir:
required: true
default: "docs/"
description: "Directory of documentation which will be used to Github wiki"
env:
GITHUB_TOKEN: "As provided by Github Actions"
runs:
using: composite
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Set up Git
run: |
git config --global user.name "GitHub Actions"
git config --global user.email "[email protected]"
shell: bash
- name: Clone Wiki Repository
run: |
git clone https://x-access-token:${{ env.GITHUB_TOKEN }}@github.com/${{ github.repository }}.wiki.git ./wiki || echo "Wiki repository not found."
shell: bash
- name: Sync Docs to Wiki
run: |
if [ ! -d "./wiki/.git" ]; then
echo "Create first page (init) https://github.com/${{ github.repository }}/wiki/_new"
exit 1
fi
if [ ! -d "./${{ inputs.dir }}" ]; then
echo "Directory ${{ inputs.dir }} does not exists."
mkdir ${{ inputs.dir }}
fi
cp -R ${{ inputs.dir }} wiki/
shell: bash
env:
GITHUB_TOKEN: ${{ env.GITHUB_TOKEN }}
- name: Commit and Push Wiki changes
run: |
cd wiki
git add .
if git diff --cached --quiet; then
echo "No changes to commit"
else
git commit -m "[Update] Wiki from repository docs"
git push origin master
fi
shell: bash
env:
GITHUB_TOKEN: ${{ env.GITHUB_TOKEN }}
- name: Cleanup
run: |
rm -R wiki/
shell: bash
env:
GITHUB_TOKEN: ${{ env.GITHUB_TOKEN }}