Skip to content

Commit d541650

Browse files
authored
CI: site previews (#2)
2 parents 713bf15 + c83941d commit d541650

File tree

3 files changed

+79
-0
lines changed

3 files changed

+79
-0
lines changed

.github/dependabot.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# To get started with Dependabot version updates, you'll need to specify which
2+
# package ecosystems to update and where the package manifests are located.
3+
# Please see the documentation for all configuration options:
4+
# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
5+
6+
version: 2
7+
updates:
8+
- package-ecosystem: "github-actions"
9+
# Workflow files stored in the
10+
# default location of `.github/workflows`
11+
directory: "/"
12+
schedule:
13+
interval: "daily"
14+
commit-message:
15+
prefix: "chore"
16+
include: "scope"
17+
labels:
18+
- "dependencies"

.github/workflows/site-preview.yml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: Site preview
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- main
7+
8+
jobs:
9+
site-preview:
10+
name: Publish site preview
11+
runs-on: ubuntu-latest
12+
permissions:
13+
pull-requests: write
14+
steps:
15+
- name: Checkout
16+
uses: actions/checkout@v4
17+
with:
18+
ref: "refs/pull/${{ github.event.number }}/merge"
19+
20+
- name: Setup Ruby
21+
uses: ruby/setup-ruby@v1
22+
with:
23+
ruby-version: "3.1"
24+
bundler-cache: true
25+
26+
- name: Build Jekyll website
27+
run: bundler exec jekyll build
28+
29+
- name: Install Netlify CLI
30+
run: npm install --location=global [email protected]
31+
32+
- name: Deploy Preview to Netlify
33+
run: |
34+
netlify deploy \
35+
--alias="${GITHUB_REPOSITORY#*/}-${{ github.event.number }}" \
36+
--auth=${{ secrets.NETLIFY_AUTH_TOKEN }} \
37+
--dir="_site" \
38+
--site=${{ vars.NETLIFY_PREVIEW_APP_SITE_ID }}
39+
40+
- name: Find existing comment
41+
uses: peter-evans/find-comment@v3
42+
id: find-comment
43+
with:
44+
issue-number: ${{ github.event.number }}
45+
comment-author: "github-actions[bot]"
46+
body-includes: "Preview url: https://"
47+
48+
- name: Add Netlify link PR comment
49+
uses: actions/github-script@v7
50+
if: steps.find-comment.outputs.comment-id == ''
51+
with:
52+
github-token: ${{ secrets.GITHUB_TOKEN }}
53+
script: |
54+
const hostnameSuffix = "compiler-previews.netlify.app"
55+
github.rest.issues.createComment({
56+
issue_number: context.issue.number,
57+
owner: context.repo.owner,
58+
repo: context.repo.repo,
59+
body: `Preview url: https://${context.repo.repo}-${{ github.event.number }}--${hostnameSuffix}`,
60+
})

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
_site/

0 commit comments

Comments
 (0)