|
| 1 | +name: Publish |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: [v*] |
| 6 | + |
| 7 | +jobs: |
| 8 | + homepage: |
| 9 | + runs-on: ubuntu-latest |
| 10 | + |
| 11 | + steps: |
| 12 | + - uses: actions/checkout@master |
| 13 | + - run: mkdir ./site |
| 14 | + - run: 'echo -e "---\nlayout: default\ntitle: Home\n---\n" > ./site/index.md' |
| 15 | + - run: 'echo "$(sed -r s"/(\{%[^%]+%\})/{% raw %}\1{% endraw %}/g" ./README.md)" >> ./site/index.md' |
| 16 | + - uses: actions/upload-artifact@v1 |
| 17 | + with: |
| 18 | + name: site |
| 19 | + path: ./site |
| 20 | + |
| 21 | + phpdoc: |
| 22 | + runs-on: ubuntu-latest |
| 23 | + |
| 24 | + steps: |
| 25 | + - uses: actions/checkout@master |
| 26 | + - name: Setup PHP, with composer and extensions |
| 27 | + uses: shivammathur/setup-php@master #https://github.com/shivammathur/setup-php |
| 28 | + with: |
| 29 | + php-version: 7.4 |
| 30 | + extensions: json |
| 31 | + coverage: pcov |
| 32 | + |
| 33 | + - name: Get composer cache directory |
| 34 | + id: composer-cache |
| 35 | + run: echo "::set-output name=dir::$(composer config cache-files-dir)" |
| 36 | + |
| 37 | + - name: Cache composer dependencies |
| 38 | + uses: actions/cache@v1 |
| 39 | + with: |
| 40 | + path: ${{ steps.composer-cache.outputs.dir }} |
| 41 | + key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} |
| 42 | + restore-keys: ${{ runner.os }}-composer- |
| 43 | + |
| 44 | + - name: Install dependencies |
| 45 | + run: | |
| 46 | + composer install --no-progress --no-suggest --prefer-dist --optimize-autoloader |
| 47 | + composer require clean/phpdoc-md --dev; |
| 48 | +
|
| 49 | + - name: Configure phpdoc-md |
| 50 | + run: | |
| 51 | + mkdir -p ./site/phpdoc; |
| 52 | +
|
| 53 | + php -d display_errors=0 -d error_reporting=0 -r "file_put_contents('.phpdoc-md','<?php |
| 54 | + return (object)[ |
| 55 | + \'rootNamespace\' => \'CssLint\', |
| 56 | + \'destDirectory\' => \'./site/phpdoc\', |
| 57 | + \'format\' => \'github\', |
| 58 | + \'classes\' => '.var_export (array_values(array_filter( |
| 59 | + array_keys(require('./vendor/composer/autoload_classmap.php')), |
| 60 | + function(\$className) { |
| 61 | + return strpos(\$className, 'CssLint') === 0; |
| 62 | + } |
| 63 | + )), true).' |
| 64 | + ]; |
| 65 | + '); |
| 66 | + "; |
| 67 | +
|
| 68 | + - name: Execute phpdoc-md |
| 69 | + run: | |
| 70 | + vendor/bin/phpdoc-md -v |
| 71 | + mv ./site/phpdoc/README.md ./site/phpdoc/index.md |
| 72 | +
|
| 73 | + - uses: actions/upload-artifact@v1 |
| 74 | + with: |
| 75 | + name: site |
| 76 | + path: ./site |
| 77 | + |
| 78 | + build_and_deploy: |
| 79 | + runs-on: ubuntu-latest |
| 80 | + needs: [homepage, phpdoc] |
| 81 | + steps: |
| 82 | + - uses: actions/download-artifact@v1 |
| 83 | + with: |
| 84 | + name: site |
| 85 | + - uses: peaceiris/actions-gh-pages@v3 |
| 86 | + with: |
| 87 | + github_token: ${{ secrets.GITHUB_TOKEN }} |
| 88 | + publish_dir: ./site |
| 89 | + enable_jekyll: true |
| 90 | + keep_files: true |
0 commit comments