From 8cb7dbe7da31bbe29b2dadd58cd7f61fbad98908 Mon Sep 17 00:00:00 2001 From: Harald Date: Sat, 13 Aug 2022 13:33:52 +0200 Subject: [PATCH 01/14] Build preview for pull request --- .drone.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.drone.yml b/.drone.yml index 8b0bcf26..7de2e154 100644 --- a/.drone.yml +++ b/.drone.yml @@ -30,7 +30,6 @@ steps: - chmod 600 ~/.ssh/id_rsa - ssh-add - rclone config create server sftp host $developer_host user $sftp_user port 22 - - "[ -z "$${DRONE_PULL_REQUEST}" ] && export TARGET=public_html || export TARGET=wildcard.manual.joomlacode.org/sites/pr-$${DRONE_PULL_REQUEST}" - rclone --dry-run -v sync build server:$TARGET when: branch: From 25b5824cb382e27bea32bd179b94965786bcd1c3 Mon Sep 17 00:00:00 2001 From: Harald Date: Sat, 13 Aug 2022 13:38:14 +0200 Subject: [PATCH 02/14] Build preview for pull request --- .drone.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.drone.yml b/.drone.yml index 7de2e154..d01ccce6 100644 --- a/.drone.yml +++ b/.drone.yml @@ -32,8 +32,6 @@ steps: - rclone config create server sftp host $developer_host user $sftp_user port 22 - rclone --dry-run -v sync build server:$TARGET when: - branch: - - main status: - success event: From 4e4f41a4b293a17b087f11fc2e4b3589b42f4431 Mon Sep 17 00:00:00 2001 From: Harald Date: Sat, 13 Aug 2022 13:42:10 +0200 Subject: [PATCH 03/14] Build preview for pull request --- .drone.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.drone.yml b/.drone.yml index d01ccce6..3c87162b 100644 --- a/.drone.yml +++ b/.drone.yml @@ -30,6 +30,7 @@ steps: - chmod 600 ~/.ssh/id_rsa - ssh-add - rclone config create server sftp host $developer_host user $sftp_user port 22 + - if [ -z "$${DRONE_PULL_REQUEST}" ]; export TARGET=public_html; endif - rclone --dry-run -v sync build server:$TARGET when: status: From 37a625b21c984aba842fdbf637940cd1c882c812 Mon Sep 17 00:00:00 2001 From: Harald Date: Sat, 13 Aug 2022 13:45:01 +0200 Subject: [PATCH 04/14] Build preview for pull request --- .drone.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.drone.yml b/.drone.yml index 3c87162b..5f4196f8 100644 --- a/.drone.yml +++ b/.drone.yml @@ -5,11 +5,11 @@ name: default clone: steps: - - name: build - image: node:18-bullseye-slim - commands: - - npm install - - npm run build +# - name: build +# image: node:18-bullseye-slim +# commands: +# - npm install +# - npm run build - name: deployment image: joomlaprojects/docker-images:packager @@ -30,7 +30,7 @@ steps: - chmod 600 ~/.ssh/id_rsa - ssh-add - rclone config create server sftp host $developer_host user $sftp_user port 22 - - if [ -z "$${DRONE_PULL_REQUEST}" ]; export TARGET=public_html; endif + - if [ -z "$${DRONE_PULL_REQUEST}" ]; then; export TARGET=public_html; else; export TARGET=wildcard.manual.joomlacode.org/sites/pr-$${DRONE_PULL_REQUEST}"; endif - rclone --dry-run -v sync build server:$TARGET when: status: From 2e70d72abf6b6141e43948a08e1617f34082e2d7 Mon Sep 17 00:00:00 2001 From: Harald Date: Sat, 13 Aug 2022 13:45:28 +0200 Subject: [PATCH 05/14] Build preview for pull request --- .drone.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.drone.yml b/.drone.yml index 5f4196f8..cc737007 100644 --- a/.drone.yml +++ b/.drone.yml @@ -13,8 +13,8 @@ steps: - name: deployment image: joomlaprojects/docker-images:packager - depends_on: - - build +# depends_on: +# - build environment: REMOTE_PRIVATE_KEY: from_secret: REMOTE_PRIVATE_KEY From b4b3c467e172e1565e29dbb18365f93591d9a793 Mon Sep 17 00:00:00 2001 From: Harald Date: Sat, 13 Aug 2022 14:05:45 +0200 Subject: [PATCH 06/14] Build preview for pull request --- .drone.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.drone.yml b/.drone.yml index cc737007..b26fd6a1 100644 --- a/.drone.yml +++ b/.drone.yml @@ -30,7 +30,8 @@ steps: - chmod 600 ~/.ssh/id_rsa - ssh-add - rclone config create server sftp host $developer_host user $sftp_user port 22 - - if [ -z "$${DRONE_PULL_REQUEST}" ]; then; export TARGET=public_html; else; export TARGET=wildcard.manual.joomlacode.org/sites/pr-$${DRONE_PULL_REQUEST}"; endif + - if [ -z "$${DRONE_PULL_REQUEST}" ]; then export TARGET=public_html; else export TARGET=wildcard.manual.joomlacode.org/sites/pr-$${DRONE_PULL_REQUEST}; fi + - eval $${TARGET} - rclone --dry-run -v sync build server:$TARGET when: status: From 5690ba00a11bc98b6431f71f2bfddff5d68f907b Mon Sep 17 00:00:00 2001 From: Harald Date: Sat, 13 Aug 2022 14:13:53 +0200 Subject: [PATCH 07/14] Build preview for pull request --- .drone.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.drone.yml b/.drone.yml index b26fd6a1..b855e00c 100644 --- a/.drone.yml +++ b/.drone.yml @@ -31,7 +31,6 @@ steps: - ssh-add - rclone config create server sftp host $developer_host user $sftp_user port 22 - if [ -z "$${DRONE_PULL_REQUEST}" ]; then export TARGET=public_html; else export TARGET=wildcard.manual.joomlacode.org/sites/pr-$${DRONE_PULL_REQUEST}; fi - - eval $${TARGET} - rclone --dry-run -v sync build server:$TARGET when: status: From 5a6bc8dc85905265433f55ce14642c8f9ab5455d Mon Sep 17 00:00:00 2001 From: Harald Date: Sat, 13 Aug 2022 14:16:21 +0200 Subject: [PATCH 08/14] Build preview for pull request --- .drone.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.drone.yml b/.drone.yml index b855e00c..97e035d8 100644 --- a/.drone.yml +++ b/.drone.yml @@ -33,6 +33,8 @@ steps: - if [ -z "$${DRONE_PULL_REQUEST}" ]; then export TARGET=public_html; else export TARGET=wildcard.manual.joomlacode.org/sites/pr-$${DRONE_PULL_REQUEST}; fi - rclone --dry-run -v sync build server:$TARGET when: + branch: + main status: - success event: From bf787f0565b37deaefd55b7d01518b6749a3db7b Mon Sep 17 00:00:00 2001 From: Harald Date: Sat, 13 Aug 2022 14:17:09 +0200 Subject: [PATCH 09/14] Build preview for pull request --- .drone.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.drone.yml b/.drone.yml index 97e035d8..b1382215 100644 --- a/.drone.yml +++ b/.drone.yml @@ -5,16 +5,16 @@ name: default clone: steps: -# - name: build -# image: node:18-bullseye-slim -# commands: -# - npm install -# - npm run build + - name: build + image: node:18-bullseye-slim + commands: + - npm install + - npm run build - name: deployment image: joomlaprojects/docker-images:packager -# depends_on: -# - build + depends_on: + - build environment: REMOTE_PRIVATE_KEY: from_secret: REMOTE_PRIVATE_KEY From 99be617934a98b5fc16b40cb30a346bd7d03d6ad Mon Sep 17 00:00:00 2001 From: Harald Date: Sat, 13 Aug 2022 14:27:43 +0200 Subject: [PATCH 10/14] Build preview for pull request --- .drone.yml | 3 +++ test.sh | 16 ++++++++++++++++ 2 files changed, 19 insertions(+) create mode 100644 test.sh diff --git a/.drone.yml b/.drone.yml index b1382215..d19ef257 100644 --- a/.drone.yml +++ b/.drone.yml @@ -32,6 +32,9 @@ steps: - rclone config create server sftp host $developer_host user $sftp_user port 22 - if [ -z "$${DRONE_PULL_REQUEST}" ]; then export TARGET=public_html; else export TARGET=wildcard.manual.joomlacode.org/sites/pr-$${DRONE_PULL_REQUEST}; fi - rclone --dry-run -v sync build server:$TARGET + - chmod +x test.sh + - if [ ! -z "$${DRONE_PULL_REQUEST}" ]; then ./test.sh "Preview" "Generated preview for this pull request" "http://$${TARGET}" ; fi; + when: branch: main diff --git a/test.sh b/test.sh new file mode 100644 index 00000000..9f9dc38c --- /dev/null +++ b/test.sh @@ -0,0 +1,16 @@ +#!/bin/sh + +HEADLINE="$1" +DESCRIPTION="$2" +TARGETURL="$3" + +if [ -z "$TARGETURL" ]; +then + echo "Headline, description and targeturl is need." + exit 1 +fi + +curl -X POST "https://api.github.com/repos/$DRONE_REPO/statuses/$DRONE_COMMIT" \ + -H "Content-Type: application/json" \ + -H "Authorization: token $GITHUB_TOKEN" \ + -d "{\"state\": \"success\", \"context\": \"$HEADLINE\", \"description\": \"DESCRIPTION\", \"target_url\": \"TARGETURL\"}" > /dev/null From eef90e772f510d0a84ccea74521a117462b7ffc3 Mon Sep 17 00:00:00 2001 From: Harald Date: Sat, 13 Aug 2022 14:31:34 +0200 Subject: [PATCH 11/14] Build preview for pull request --- .drone.yml | 2 +- test.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.drone.yml b/.drone.yml index d19ef257..0fac9ab6 100644 --- a/.drone.yml +++ b/.drone.yml @@ -31,7 +31,7 @@ steps: - ssh-add - rclone config create server sftp host $developer_host user $sftp_user port 22 - if [ -z "$${DRONE_PULL_REQUEST}" ]; then export TARGET=public_html; else export TARGET=wildcard.manual.joomlacode.org/sites/pr-$${DRONE_PULL_REQUEST}; fi - - rclone --dry-run -v sync build server:$TARGET + - rclone -v sync build server:$TARGET - chmod +x test.sh - if [ ! -z "$${DRONE_PULL_REQUEST}" ]; then ./test.sh "Preview" "Generated preview for this pull request" "http://$${TARGET}" ; fi; diff --git a/test.sh b/test.sh index 9f9dc38c..f957df7f 100644 --- a/test.sh +++ b/test.sh @@ -13,4 +13,4 @@ fi curl -X POST "https://api.github.com/repos/$DRONE_REPO/statuses/$DRONE_COMMIT" \ -H "Content-Type: application/json" \ -H "Authorization: token $GITHUB_TOKEN" \ - -d "{\"state\": \"success\", \"context\": \"$HEADLINE\", \"description\": \"DESCRIPTION\", \"target_url\": \"TARGETURL\"}" > /dev/null + -d "{\"state\": \"success\", \"context\": \"$HEADLINE\", \"description\": \"$DESCRIPTION\", \"target_url\": \"$TARGETURL\"}" > /dev/null From 44b5db542762f63daffd056bde8f9e9bf58a97b7 Mon Sep 17 00:00:00 2001 From: Harald Date: Sat, 13 Aug 2022 14:53:43 +0200 Subject: [PATCH 12/14] Build preview for pull request --- .drone.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.drone.yml b/.drone.yml index 0fac9ab6..2bec8479 100644 --- a/.drone.yml +++ b/.drone.yml @@ -22,6 +22,8 @@ steps: from_secret: developer_host sftp_user: from_secret: sftp_user + GITHUB_TOKEN: + from_secret: github_token commands: - mkdir -p ~/.ssh - eval $(ssh-agent -s) From f3dfebd8b90ddb6f0755227a0afc1e1aa07c4bc7 Mon Sep 17 00:00:00 2001 From: Harald Date: Sat, 13 Aug 2022 15:04:09 +0200 Subject: [PATCH 13/14] Build preview for pull request --- .drone.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.drone.yml b/.drone.yml index 2bec8479..df598bf3 100644 --- a/.drone.yml +++ b/.drone.yml @@ -14,7 +14,7 @@ steps: - name: deployment image: joomlaprojects/docker-images:packager depends_on: - - build + - build environment: REMOTE_PRIVATE_KEY: from_secret: REMOTE_PRIVATE_KEY @@ -35,8 +35,7 @@ steps: - if [ -z "$${DRONE_PULL_REQUEST}" ]; then export TARGET=public_html; else export TARGET=wildcard.manual.joomlacode.org/sites/pr-$${DRONE_PULL_REQUEST}; fi - rclone -v sync build server:$TARGET - chmod +x test.sh - - if [ ! -z "$${DRONE_PULL_REQUEST}" ]; then ./test.sh "Preview" "Generated preview for this pull request" "http://$${TARGET}" ; fi; - + - 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; when: branch: main @@ -48,6 +47,6 @@ steps: --- kind: signature -hmac: 348c8ac11879e5515a5b167c9af1a7d6bba2f3bd66408a291f4f9f6ff27d8204 +hmac: 3d1303abd175ffda3aec141c6ea71d541f50f3c3e0752a68330fde5560386a58 ... From 715e2e01dd439056280a4f9b5c95fd888ead107e Mon Sep 17 00:00:00 2001 From: Harald Date: Sat, 13 Aug 2022 15:14:44 +0200 Subject: [PATCH 14/14] Add description to the readme --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index b3c227f0..c4c175ae 100644 --- a/README.md +++ b/README.md @@ -30,7 +30,11 @@ $ npm run build This command generates static content into the `build` directory and can be served using any static contents hosting service. +### Preview for pull request +As part of the documentation validation we create a subdomain for previewing your pull request. +The Link will be added to the "checks" section in the pull request as "preview". The url used +is http://pr-[prnumber].manual.joomlacode.org ## How to use