Merge pull request #7833 from takano32/fix-phpDocumentor-GitHub-Actions #1231
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# When changes are pushed to the develop branch, | |
# build the current version of the API documentation | |
# with phpDocumentor and deploy it to codeigniter4/api. | |
name: Deploy API Documentation | |
on: | |
push: | |
branches: | |
- 'develop' | |
paths: | |
- 'system/**' | |
- '.github/workflows/deploy-apidocs.yml' | |
permissions: | |
contents: read | |
jobs: | |
build: | |
name: Deploy to api | |
permissions: | |
contents: write | |
if: github.repository == 'codeigniter4/CodeIgniter4' | |
runs-on: ubuntu-22.04 | |
steps: | |
- name: Setup credentials | |
run: | | |
git config --global user.email "[email protected]" | |
git config --global user.name "${GITHUB_ACTOR}" | |
- name: Checkout source | |
uses: actions/checkout@v3 | |
with: | |
path: source | |
- name: Checkout target | |
uses: actions/checkout@v3 | |
with: | |
repository: codeigniter4/api | |
token: ${{ secrets.ACCESS_TOKEN }} | |
path: api | |
- name: Setup PHP | |
uses: shivammathur/setup-php@v2 | |
with: | |
php-version: '8.0' | |
tools: phive | |
coverage: none | |
- name: Download latest phpDocumentor | |
working-directory: source | |
run: phive install --force-accept-unsigned phpDocumentor | |
- name: Prepare API repo | |
working-directory: api | |
run: | | |
git reset --hard master | |
rm -rfv docs | |
mkdir --parents --verbose docs | |
- name: Build API in source repo | |
working-directory: source | |
run: | | |
php tools/phpDocumentor run --ansi --verbose | |
cp -R ${GITHUB_WORKSPACE}/source/api/build/* ${GITHUB_WORKSPACE}/api/docs | |
- name: Deploy to API repo | |
working-directory: api | |
run: | | |
git add . | |
if ! git diff-index --quiet HEAD; then | |
git commit -m "Updated API for commit ${GITHUB_SHA}" | |
git push origin master | |
fi |