Skip to content

Commit 4062056

Browse files
authored
Create a preview for each pull request (#14)
* Build preview for pull request * Add description to the readme
1 parent fd5875b commit 4062056

File tree

3 files changed

+28
-4
lines changed

3 files changed

+28
-4
lines changed

.drone.yml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ steps:
2222
from_secret: developer_host
2323
sftp_user:
2424
from_secret: sftp_user
25+
GITHUB_TOKEN:
26+
from_secret: github_token
2527
commands:
2628
- mkdir -p ~/.ssh
2729
- eval $(ssh-agent -s)
@@ -30,11 +32,13 @@ steps:
3032
- chmod 600 ~/.ssh/id_rsa
3133
- ssh-add
3234
- rclone config create server sftp host $developer_host user $sftp_user port 22
33-
- "[ -z "$${DRONE_PULL_REQUEST}" ] && export TARGET=public_html || export TARGET=wildcard.manual.joomlacode.org/sites/pr-$${DRONE_PULL_REQUEST}"
34-
- rclone --dry-run -v sync build server:$TARGET
35+
- if [ -z "$${DRONE_PULL_REQUEST}" ]; then export TARGET=public_html; else export TARGET=wildcard.manual.joomlacode.org/sites/pr-$${DRONE_PULL_REQUEST}; fi
36+
- rclone -v sync build server:$TARGET
37+
- chmod +x test.sh
38+
- if [ ! -z "$${DRONE_PULL_REQUEST}" ]; then /bin/add_github_status.sh "Preview" "Generated preview for this pull request" "http://pr-$${DRONE_PULL_REQUEST}.manual.joomlacode.org" ; fi;
3539
when:
3640
branch:
37-
- main
41+
main
3842
status:
3943
- success
4044
event:
@@ -43,6 +47,6 @@ steps:
4347

4448
---
4549
kind: signature
46-
hmac: 348c8ac11879e5515a5b167c9af1a7d6bba2f3bd66408a291f4f9f6ff27d8204
50+
hmac: 3d1303abd175ffda3aec141c6ea71d541f50f3c3e0752a68330fde5560386a58
4751

4852
...

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,11 @@ $ npm run build
3030

3131
This command generates static content into the `build` directory and can be served using any static contents hosting service.
3232

33+
### Preview for pull request
3334

35+
As part of the documentation validation we create a subdomain for previewing your pull request.
36+
The Link will be added to the "checks" section in the pull request as "preview". The url used
37+
is http://pr-[prnumber].manual.joomlacode.org
3438

3539
## How to use
3640

test.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/bin/sh
2+
3+
HEADLINE="$1"
4+
DESCRIPTION="$2"
5+
TARGETURL="$3"
6+
7+
if [ -z "$TARGETURL" ];
8+
then
9+
echo "Headline, description and targeturl is need."
10+
exit 1
11+
fi
12+
13+
curl -X POST "https://api.github.com/repos/$DRONE_REPO/statuses/$DRONE_COMMIT" \
14+
-H "Content-Type: application/json" \
15+
-H "Authorization: token $GITHUB_TOKEN" \
16+
-d "{\"state\": \"success\", \"context\": \"$HEADLINE\", \"description\": \"$DESCRIPTION\", \"target_url\": \"$TARGETURL\"}" > /dev/null

0 commit comments

Comments
 (0)