Skip to content

Commit 58e9d9c

Browse files
authored
Using phpdocs-wiki-update-action action
1 parent 2ffcfa6 commit 58e9d9c

File tree

1 file changed

+7
-79
lines changed

1 file changed

+7
-79
lines changed

.github/workflows/update-wiki.yml

Lines changed: 7 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -13,82 +13,10 @@ jobs:
1313
steps:
1414
- name: Checkouting main code
1515
uses: actions/checkout@v2
16-
- name: Parsing git info
17-
run: |
18-
echo "::set-env name=LAST_COMMIT_AUTHOR_EMAIL::$(git show -s --format='%ae' HEAD)"
19-
echo "::set-env name=LAST_COMMIT_AUTHOR_NAME::$(git show -s --format='%an' HEAD)"
20-
BRANCH_NAME=$(git rev-parse --abbrev-ref HEAD)
21-
if [ "$BRANCH_NAME" == 'HEAD' ]; then
22-
BRANCH_NAME=$(git describe --tags --abbrev=0)
23-
fi;
24-
echo "::set-env name=BRANCH_NAME::$BRANCH_NAME"
25-
- name: Checking for required secrets
26-
run: |
27-
if [ -z "${{ secrets.WIKI_GITHUB_UPDATE_TOKEN }}" ]; then
28-
echo "Secret WIKI_GITHUB_UPDATE_TOKEN is missing. Use this link to create required token -> https://github.com/settings/tokens/new?scopes=repo&description=wiki%20api%20generator <- and than add to project secrets."
29-
exit 1
30-
fi;
31-
if [ -z "${{ secrets.WIKI_GITHUB_UPDATE_USER }}" ]; then
32-
echo "Secret WIKI_GITHUB_UPDATE_USER is missing. Set this to username for who token belongs."
33-
exit 2
34-
fi;
35-
- name: Cloning old wiki
36-
run: |
37-
mkdir .docs.old
38-
cd .docs.old
39-
git init
40-
git remote add origin https://${{ secrets.WIKI_GITHUB_UPDATE_USER }}:${{ secrets.WIKI_GITHUB_UPDATE_TOKEN }}@github.com/${{ github.repository }}.wiki.git
41-
git config --local gc.auto 0
42-
git -c protocol.version=2 fetch --no-tags --prune --progress --no-recurse-submodules --depth=1 origin
43-
git checkout ${BRANCH_NAME} 2>/dev/null || git checkout -b ${BRANCH_NAME}
44-
git reset --hard
45-
cd ..
46-
- name: Installing hidden clean/phpdoc-md
47-
run: composer require --dev clean/phpdoc-md
48-
- name: Creating configuration
49-
run: |
50-
cat > .phpdoc-md <<EOF
51-
<?php
52-
return (object)[
53-
'rootNamespace' => 'Imponeer',
54-
'destDirectory' => '.docs',
55-
'format' => 'github',
56-
'classes' => [
57-
'\Imponeer\ToArrayInterface',
58-
],
59-
];
60-
EOF
61-
- name: View config
62-
run: cat .phpdoc-md
63-
- name: Generating docs...
64-
run: ./vendor/bin/phpdoc-md
65-
- name: Updating docs folder
66-
run: cp -r ./.docs.old/.git ./.docs/.git
67-
- name: Renaming README.md -> HOME.md
68-
working-directory: .docs/
69-
run: mv README.md HOME.md
70-
- name: Fixing autogenerated markdown file contents
71-
working-directory: .docs/
72-
run: |
73-
find *.md -type f -exec sed -i 's/\.md//g' {} \;
74-
sed -i '1d' HOME.md
75-
sed -i '1i# API Documentation' HOME.md
76-
sed -i '2i> Notice: Wiki was automatic generated from project sources as project API documentation. Do not edit manually!' HOME.md
77-
sed -i "3i\ " HOME.md
78-
- name: Configuring commit author
79-
working-directory: .docs/
80-
run: |
81-
git config --local user.email "$LAST_COMMIT_AUTHOR_EMAIL"
82-
git config --local user.name "$LAST_COMMIT_AUTHOR_NAME"
83-
- name: Checking what docs where updated
84-
working-directory: .docs/
85-
run: git status
86-
- name: Commiting docs update
87-
working-directory: .docs/
88-
run: |
89-
git add -u :/
90-
git add .
91-
git commit -m "Automatically generated for https://github.com/${{ github.repository }}/commit/${GITHUB_SHA}" || true
92-
- name: Pushing docs update
93-
working-directory: .docs/
94-
run: git push -u origin ${BRANCH_NAME}
16+
- name: Update wiki
17+
uses: impresscms-dev/phpdocs-wiki-update-action@master
18+
with:
19+
wiki_github_update_token: ${{secrets.WIKI_GITHUB_UPDATE_TOKEN}}
20+
wiki_github_update_user: ${{secrets.WIKI_GITHUB_UPDATE_USER}}
21+
class_root_namespace: Imponeer
22+
include: Imponeer\**

0 commit comments

Comments
 (0)