-
Notifications
You must be signed in to change notification settings - Fork 0
76 lines (63 loc) · 2.15 KB
/
Copy pathdeploy-preview.yml
File metadata and controls
76 lines (63 loc) · 2.15 KB
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
name: Deploy Preview
on:
pull_request:
types: [opened, synchronize, reopened]
permissions:
contents: write
pull-requests: write
concurrency:
group: eeid-doc-preview-${{ github.event.pull_request.number }}
cancel-in-progress: true
jobs:
deploy-preview:
runs-on: ubuntu-latest
env:
ruby-version: '3.0'
steps:
- uses: actions/checkout@v4
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ env.ruby-version }}
- uses: actions/cache@v3
with:
path: vendor/bundle
key: gems-${{ runner.os }}-${{ env.ruby-version }}-${{ hashFiles('**/Gemfile.lock') }}
restore-keys: |
gems-${{ runner.os }}-${{ env.ruby-version }}-
gems-${{ runner.os }}-
- run: bundle config set deployment 'true'
- name: bundle install
run: |
bundle config path vendor/bundle
bundle install --jobs 4 --retry 3
- run: bundle exec middleman build
- name: Deploy preview
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./build
destination_dir: previews/pr-${{ github.event.pull_request.number }}
keep_files: true
- name: Add preview access note
run: |
preview_url="https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}/previews/pr-${{ github.event.pull_request.number }}/"
{
echo "## Docs Preview"
echo
echo "Preview deployed successfully."
echo
echo "Access it here: ${preview_url}"
} >> "$GITHUB_STEP_SUMMARY"
- name: Comment preview URL
uses: actions/github-script@v7
with:
script: |
const previewUrl = `https://${context.repo.owner}.github.io/${context.repo.repo}/previews/pr-${context.issue.number}/`;
const body = `## Docs Preview\n\nPreview deployed successfully.\n\nAccess it here: ${previewUrl}`;
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body
});