You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by zr...@apache.org on 2019/03/03 17:36:47 UTC

[camel-website] branch master updated: refactor: simplified GitHub actions workflow

This is an automated email from the ASF dual-hosted git repository.

zregvart pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel-website.git


The following commit(s) were added to refs/heads/master by this push:
     new a0ff272  refactor: simplified GitHub actions workflow
a0ff272 is described below

commit a0ff2724c0bb4905b85f277d7b9e4f6fca9f92cc
Author: Zoran Regvart <zr...@gmail.com>
AuthorDate: Sun Mar 3 18:36:40 2019 +0100

    refactor: simplified GitHub actions workflow
    
    This version of the workflow just builds, filters on the `master` branch
    and performs the publish.
---
 .github/action-website/publish | 23 ++++++-----------------
 .github/main.workflow          |  8 +++++++-
 2 files changed, 13 insertions(+), 18 deletions(-)

diff --git a/.github/action-website/publish b/.github/action-website/publish
index 760b09d..9f3cc37 100755
--- a/.github/action-website/publish
+++ b/.github/action-website/publish
@@ -2,28 +2,17 @@
 
 set -euxo pipefail
 
-is_pull_request=$(jq -r .pull_request $GITHUB_EVENT_PATH)
-ref=$(jq -r .ref $GITHUB_EVENT_PATH)
+REV=$(cd "$GITHUB_WORKSPACE" && git rev-parse --short HEAD)
 
-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=.
-fi
-
-PUBLISH_DIR=$(mktemp -d /tmp/publish.XXXXXXXX)
-cd $PUBLISH_DIR
+PUBLISH_DIR=$(mktemp -d "/${TMPDIR}/publish.XXXXXXXX")
+cd "$PUBLISH_DIR"
 
 git clone -b asf-site https://github.com/apache/camel-website.git .
 git config user.email dev@camel.apache.org
-git config user.name $GITHUB_ACTOR
-mkdir -p $DEST_DIR
-cd $DEST_DIR
+git config user.name "$GITHUB_ACTOR"
 git rm -r --ignore-unmatch *
-cp -Rvn $GITHUB_WORKSPACE/public/* .
+cp -Rvn "${GITHUB_WORKSPACE}/public/"* .
 git add .
-git commit -m "Website updated to $(git rev-parse --short HEAD)"
+git commit -m "Website updated to ${REV}"
 git push origin asf-site
 
diff --git a/.github/main.workflow b/.github/main.workflow
index 25846c6..e0360e5 100644
--- a/.github/main.workflow
+++ b/.github/main.workflow
@@ -16,9 +16,15 @@ action "Build website" {
   args = "--non-interactive --frozen-lockfile"
 }
 
+action "On master branch" {
+  uses = "actions/bin/filter@d820d56839906464fb7a57d1b4e1741cf5183efa"
+  needs = ["Build website"]
+  args = "branch master"
+}
+
 action "Publish" {
   uses = "./.github/action-website"
-  needs = ["Build website"]
+  needs = ["On master branch"]
   runs = "publish"
   secrets = ["GITHUB_TOKEN"]
 }