Skip to content

Commit eeedf24

Browse files
committed
Pretend to be PR events to deploy previews.
1 parent 878cb23 commit eeedf24

File tree

3 files changed

+24
-6
lines changed

3 files changed

+24
-6
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ on:
44
push:
55
branches:
66
- 'master'
7-
- 'create-pull-request/patch'
7+
- 'create-pull-request/package-update'
88
tags: '*'
99
pull_request:
1010

.github/workflows/pkg-update.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ jobs:
2727
uses: peter-evans/create-pull-request@v3
2828
with:
2929
title: 'Automatic Pkg.update()'
30+
branch: 'create-pull-request/package-update'
3031
author: 'GitHub <[email protected]>'
3132
body: |
3233
Automatic `Pkg.update()` with the following changes:

make.jl

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,25 @@ makedocs(
9797
),
9898
)
9999

100-
deploydocs(
101-
versions = nothing,
102-
push_preview = true,
103-
repo = "github.com/JuliaLogging/julialogging.github.io.git",
104-
)
100+
# Hack to deploy preview builds from package auto-update
101+
# This is necessary since when using the create-pull-request action, the PR is opened
102+
# by the github-actions user authenticating with the default GITHUB_TOKEN, which also
103+
# means that regular CI will not be triggered. This is circumvented by using a SSH key
104+
# with the actions/checkout action when cloning, which means that the resulting commit
105+
# is pushed with the same SSH key triggering a "push" event build. However, Documenter
106+
# only builds previews for the "pull_request" event type, so we need to pretend to be
107+
# a "pull_request" event type by temporarily setting some environment variables.
108+
env = Dict{String,String}()
109+
if ENV["GITHUB_EVENT_NAME"] == "push" &&
110+
ENV["GITHUB_REF"] == "refs/heads/create-pull-request/package-update"
111+
env["GITHUB_EVENT_NAME"] = "pull_request"
112+
env["GITHUB_REF"] = "refs/pull/1234/merge"
113+
end
114+
115+
withenv(env...) do
116+
deploydocs(
117+
versions = nothing,
118+
push_preview = true,
119+
repo = "github.com/JuliaLogging/julialogging.github.io.git",
120+
)
121+
end

0 commit comments

Comments
 (0)