-
-
Notifications
You must be signed in to change notification settings - Fork 5
85 lines (67 loc) · 3 KB
/
deploy-documentation-preview.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
84
85
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