-
Notifications
You must be signed in to change notification settings - Fork 29
83 lines (83 loc) · 3.1 KB
/
core-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
name: Publish Core Docs
on: [push, pull_request]
jobs:
make-restapi-docs:
name: Checkout phpList core and generate docs using `phpDocumentor`
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup PHP, with composer and extensions
uses: shivammathur/setup-php@v2 #https://github.com/shivammathur/setup-php
with:
php-version: 7.4
extensions: mbstring, dom, fileinfo, mysql
- name: Get composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Cache composer dependencies
uses: actions/cache@v2
with:
path: ${{ steps.composer-cache.outputs.dir }}
# Use composer.json for key, if composer.lock is not committed.
# key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-
- name: Install current dependencies from composer.lock
run: composer install
- name: Install phpDocumentor
run: |
wget https://phpdoc.org/phpDocumentor.phar
chmod +x phpDocumentor.phar
mv phpDocumentor.phar /usr/local/bin/phpDocumentor
- name: Generate documentation
run: composer run-php-documentor
- name: zip phpdocumentor dir
run: zip -r phpdocumentor.zip docs/phpdocumentor
- name: Upload generated doc files
uses: actions/upload-artifact@v2
with:
name: doc-files
path: phpdocumentor.zip
deploy-docs:
name: Deploy Core Docs.
runs-on: ubuntu-20.04
needs: make-restapi-docs
steps:
- name: Checkout phplist/core-docs
uses: actions/checkout@v2
with:
repository: phpList/core-docs
fetch-depth: 0
token: ${{ secrets.PUSH_CORE_DOCS }}
- name: Restore REST API Spec
uses: actions/download-artifact@v2
with:
name: doc-files
- name: unzip phpdocumentor
run: |
unzip phpdocumentor.zip
rm phpdocumentor.zip
- name: List Files
run: ls
- name: Sync old files with newly generated ones.
run: rsync -av docs/phpdocumentor/* .
- name: Removed temp dirs
run: rm -rf docs
- name: Check if updates/changes.
run: git status --porcelain > repo-changes.txt
- name: Check changes file
run: cat repo-changes.txt
- name: Verify updates.
id: allow-deploy
run: |
if [ -s repo-changes.txt ]; then echo "Updates made to documentation"; echo '::set-output name=DEPLOY::true'; else echo "No updates made to documentation deployment would be skipped."; echo '::set-output name=DEPLOY::false'; fi
- name: Commit changes and deply
if: ${{ steps.allow-deploy.outputs.DEPLOY == 'true' }}
run: |
rm repo-changes.txt
git config user.name "github-actions"
git config user.email "[email protected]"
git add .
git commit -s -m "phplist/core docs deployment `date`"
git push