Skip to content

HydePHP v2.x Development #1484

HydePHP v2.x Development

HydePHP v2.x Development #1484

name: Deploy Documentation Preview
on:
pull_request:
branches: [ "master" ]
paths:
- 'docs/**'
- '.github/workflows/deploy-documentation-preview.yml'
jobs:
build-and-deploy-documentation-preview:
if: "! contains(github.event.pull_request.labels.*.name, 'pause-pages')"
environment:
name: pr-documentation-${{ github.event.pull_request.number }}
url: https://ci.hydephp.com/previews/develop/${{ github.event.pull_request.number }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Cache Composer packages
id: composer-cache
uses: actions/cache@v4
with:
path: vendor
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-php-
- name: Install Composer Dependencies
run: composer install --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist
- name: Copy configuration from the configuration directory
run: cp -r monorepo/gh-pages/gh-pages-config-dev-docs/* .
- name: Update configuration files
run: |
echo "output_directories:" >> hyde.yml
echo " Hyde\Pages\DocumentationPage: ''" >> hyde.yml
sed -i "s/'header' => env('SITE_NAME', 'HydePHP').' Docs'/'header' => 'PR #${{ github.event.pull_request.number }} - Docs'/g" config/docs.php
- name: Create component to add an information badge
run: |
mkdir -p resources/views/vendor/hyde/layouts
cp vendor/hyde/framework/resources/views/layouts/docs.blade.php resources/views/vendor/hyde/layouts/docs.blade.php
- name: Configure environment variables
run: |
echo 'SITE_NAME="HydePHP Documentation Preview"' >> .env
echo 'SITE_URL="https://ci.hydephp.com/previews/develop/${{ github.event.pull_request.number }}"' >> .env
- name: Move documentation files
run: rm -rf _docs && mv -f docs _docs
- name: Compile the static site
run: php hyde build
- name: Package the static site
run: zip -r site.zip _site
- name: Sign the artifact
run: |
echo '${{ secrets.CI_PREVIEW_SIGNING_RSA_PRIVATE_KEY }}' > private.pem
openssl dgst -sha256 -sign private.pem -out signature.bin site.zip
unlink private.pem
- name: Upload the artifact
run: |
repository="develop"
bearerToken="${{ secrets.CI_SERVER_TOKEN }}"
pullRequest="${{ github.event.pull_request.number }}"
signature="$(openssl base64 -in signature.bin)"
artifact="site.zip"
curl -X POST --fail-with-body \
-H "Content-Type: multipart/form-data" \
-H "Authorization: Bearer $bearerToken" \
-F "repository=$repository" \
-F "pullRequest=$pullRequest" \
-F "artifact=@$artifact" \
-F "signature=$signature" \
https://ci.hydephp.com/api/deployment-previews