This repository has been archived by the owner on Feb 14, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
65 lines (55 loc) · 2.24 KB
/
pr_preview_publish.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
---
name: Publish PR preview
on: [ pull_request_target ]
env:
IMAGE_NAME: doctools-builder-test
WORKSPACE_DIR: /workspace
jobs:
deploy:
name: Build and publish PR preview
runs-on: ubuntu-latest
environment: preview
permissions:
contents: write
pull-requests: write
steps:
- name: Checkout code from repos
uses: actions/checkout@v3
with:
ref: refs/pull/${{ github.event.number }}/merge # required to pull the PR code instead of the main one
fetch-depth: 0 # Required for mkdocs to be able to display pages last update info
- name: Get additional Github env vars # vars from Github env, can not be modified by users
uses: FranzDiebold/github-env-vars-action@b9b3a88cfa3ad9bde40c291143c28f918e2d1668 #v2.3.0
- name: Generate PR slug
shell: sh
id: generate_pr_slug
run: echo "::set-output name=slug::PR-${{ github.event.number }}"
- name: Build test image
shell: sh
run: |
docker build . --tag $IMAGE_NAME --build-arg WORKSPACE_DIR=$WORKSPACE_DIR
- name: Build preview site
shell: sh
run: |
docker run --rm \
-e VERSION=test \
-v ${PWD}:$WORKSPACE_DIR \
-w $WORKSPACE_DIR \
$IMAGE_NAME \
build -s \
--config-file /workspace/tests/mkdocs.yml
- name: Deploy Preview
uses: JamesIves/github-pages-deploy-action@6ce741f5d4e01e15f9ea5ec96df1a43f522c330f #4.1.7
with:
branch: pr-preview # The branch the action should deploy to.
folder: tests/site # The folder the action should deploy.
target-folder: ${{ steps.generate_pr_slug.outputs.slug }}
commit-message: Preview for ${{ steps.generate_pr_slug.outputs.slug }}
single-commit: true
- name: Add comment with link to preview doc
uses: marocchino/sticky-pull-request-comment@39c5b5dc7717447d0cba270cd115037d32d28443 #v2.2.0
with:
header: preview
recreate: true
message: |
[Doc preview for this PR #${{ github.event.number }} is available](https://${{ env.CI_REPOSITORY_OWNER }}.github.io/${{ env.CI_REPOSITORY_NAME }}/${{ steps.generate_pr_slug.outputs.slug }}/)