@@ -9,6 +9,14 @@ branding:
9
9
color : yellow
10
10
11
11
inputs :
12
+ token :
13
+ description : >
14
+ The token to use for the deployment.
15
+ Default is GITHUB_TOKEN in the current repository.
16
+ If you need more permissions for things such as deploying to another
17
+ repository, you can add a Personal Access Token (PAT).
18
+ required : false
19
+ default : ${{ github.token }}
12
20
preview-branch :
13
21
description : Branch on which the previews will be deployed.
14
22
required : false
@@ -21,6 +29,18 @@ inputs:
21
29
description : Directory containing files to deploy.
22
30
required : false
23
31
default : .
32
+ deploy-repository :
33
+ description : >
34
+ The GitHub repository to deploy the preview to.
35
+ This should be formatted like `<org name>/<repo name>`, e.g.
36
+ `rossjrw/pr-preview-action`.
37
+ Defaults to the current repository.
38
+
39
+ You will need to add a Personal Access Token (PAT) in the `token` input
40
+ in order to allow the action running in one repository to make changes
41
+ to another repository.
42
+ required : false
43
+ default : ${{ github.repository }}
24
44
custom-url :
25
45
description : Custom pages URL
26
46
required : false
@@ -60,20 +80,22 @@ runs:
60
80
actionref : ${{ github.action_ref }}
61
81
actionrepo : ${{ github.action_repository }}
62
82
customurl : ${{ inputs.custom-url }}
83
+ deployrepo : ${{ inputs.deploy-repository }}
84
+ token : ${{ inputs.token }}
63
85
run : |
64
86
echo "action=$action" >> $GITHUB_ENV
65
87
echo "targetdir=$umbrella/pr-$pr" >> $GITHUB_ENV
66
88
echo "pr=$pr" >> $GITHUB_ENV
67
89
68
- org=$(echo "$GITHUB_REPOSITORY " | cut -d "/" -f 1)
69
- thirdleveldomain=$(echo "$GITHUB_REPOSITORY " | cut -d "/" -f 2)
90
+ org=$(echo "$deployrepo " | cut -d "/" -f 1)
91
+ thirdleveldomain=$(echo "$deployrepo " | cut -d "/" -f 2)
70
92
71
93
if [ ! -z "$customurl" ]; then
72
94
pagesurl="$customurl"
73
95
elif [ "${org}.github.io" == "$thirdleveldomain" ]; then
74
96
pagesurl="${org}.github.io"
75
97
else
76
- pagesurl=$(echo "$GITHUB_REPOSITORY " | sed 's/\//.github.io\//')
98
+ pagesurl=$(echo "$deployrepo " | sed 's/\//.github.io\//')
77
99
fi
78
100
79
101
echo "pagesurl=$pagesurl" >> $GITHUB_ENV
83
105
84
106
echo "actionref=$actionref" >> $GITHUB_ENV
85
107
echo "actionrepo=$actionrepo" >> $GITHUB_ENV
108
+ echo "deployrepo=$deployrepo" >> $GITHUB_ENV
109
+ echo "token=$token" >> $GITHUB_ENV
86
110
shell : bash
87
111
88
112
- name : Determine action version
@@ -100,6 +124,8 @@ runs:
100
124
if : env.action == 'deploy'
101
125
uses : JamesIves/github-pages-deploy-action@v4
102
126
with :
127
+ token : ${{ env.token }}
128
+ repository-name : ${{ env.deployrepo }}
103
129
branch : ${{ inputs.preview-branch }}
104
130
folder : ${{ inputs.source-dir }}
105
131
target-folder : ${{ env.targetdir }}
@@ -136,6 +162,8 @@ runs:
136
162
if : env.action == 'remove'
137
163
uses : JamesIves/github-pages-deploy-action@v4
138
164
with :
165
+ token : ${{ env.token }}
166
+ repository-name : ${{ env.deployrepo }}
139
167
branch : ${{ inputs.preview-branch }}
140
168
folder : ${{ env.emptydir }}
141
169
target-folder : ${{ env.targetdir }}
0 commit comments