This is an automated email from the ASF dual-hosted git repository. zregvart pushed a commit to branch pr/deployment in repository https://gitbox.apache.org/repos/asf/camel-website.git
commit cb5fcaa802f3232912f91fe57583d5a9883163a0 Author: Zoran Regvart <zregvart+git...@gmail.com> AuthorDate: Sun Mar 3 16:19:37 2019 +0100 chore: GitHub deployments Creates a GitHub deployment for previews and staging environment. --- .github/action-website/publish | 44 ++++++++++++++++++++++++++++++++++++++---- 1 file changed, 40 insertions(+), 4 deletions(-) diff --git a/.github/action-website/publish b/.github/action-website/publish index fa7cacf..461727b 100755 --- a/.github/action-website/publish +++ b/.github/action-website/publish @@ -2,17 +2,53 @@ set -euxo pipefail -REV=$(cd "$GITHUB_WORKSPACE" && git rev-parse --short HEAD) +IS_PULL_REQUEST=$(jq -r .pull_request $GITHUB_EVENT_PATH) +REF=$(jq -r .ref $GITHUB_EVENT_PATH) +ENVIRONMENT="preview" +TRANSIENT="true" + +if [ "$IS_PULL_REQUEST" != "null" ]; then + DEST_DIR="preview/PR/$(jq .pull_request.number $GITHUB_EVENT_PATH)" +elif [ "$REF" != "ref/heads/master" ]; then + DEST_DIR="preview/branch/${REF##*/}" +else + DEST_DIR=. + ENVIRONMENT="staging" + TRANSIENT="false" +fi PUBLISH_DIR=$(mktemp -d /tmp/publish.XXXXXXXX) cd $PUBLISH_DIR git clone -b asf-site https://github.com/apache/camel-website.git . git config user.email d...@camel.apache.org -git config user.name "$GITHUB_ACTOR" +git config user.name $GITHUB_ACTOR +mkdir -p $DEST_DIR +cd $DEST_DIR git rm -r --ignore-unmatch * -cp -Rvn "${GITHUB_WORKSPACE}/public/"* . +cp -Rvn $GITHUB_WORKSPACE/public/* . git add . -git commit -m "Website updated to ${REV}" +git commit -m "Website updated to $(git rev-parse --short HEAD)" git push origin asf-site +URI=https://api.github.com +API_HEADER="Accept: application/vnd.github.ant-man-preview+json" +AUTH_HEADER="Authorization: token ${GITHUB_TOKEN}" + +IFS='' read -r -d '' DEPLOYMENT_JSON<<"EOF" +{ + "ref": "${REF}", + "auto_merge": false, + "environment": "${ENVIRONMENT}" + "description": "Website built and deployed to ${ENVIRONMENT} environment", + "transient": ${TRANSIENT}, + "payload": "https://apache.camel.com/staging/${DEST_DIR}", + "description": "Deploy request from hubot" +} +EOF + +curl -XPOST -sSL \ + -H "${AUTH_HEADER}" \ + -H "${API_HEADER}" \ + -d "${DEPLOYMENT_JSON}" \ + "${URI}/repos/apache/camel-website"