From 2f1196a43b064569f8c40559a17c85aeff9b6923 Mon Sep 17 00:00:00 2001 From: CrazyMax Date: Tue, 3 Sep 2019 04:38:29 +0200 Subject: [PATCH] Use inputs as env --- README.md | 5 ++--- entrypoint.sh | 15 ++++++--------- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index eabde2975e0..ab66ef3f96e 100644 --- a/README.md +++ b/README.md @@ -58,10 +58,9 @@ Docker :whale: image is also provided and automatically updated within [Docker H - name: Deploy if: success() uses: docker://crazymax/ghaction-github-pages - with: - target_branch: gh-pages - build_dir: public env: + INPUT_TARGET_BRANCH: gh-pages + INPUT_BUILD_DIR: public GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} ``` diff --git a/entrypoint.sh b/entrypoint.sh index 0a8e572be33..7f38ebf2125 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,28 +1,25 @@ #!/bin/sh set -e -TARGET_BRANCH=$1 -BUILD_DIR=$2 - -if [ -z "$TARGET_BRANCH" ]; then +if [ -z "$INPUT_TARGET_BRANCH" ]; then echo "⛔️ Target branch not defined" exit 1 fi -if [ ! -d "$BUILD_DIR" ]; then +if [ ! -d "$INPUT_BUILD_DIR" ]; then echo "⛔️ Build dir does not exist" exit 1 fi -echo "🏃 Deploying $BUILD_DIR directory to $TARGET_BRANCH branch" -cd "$BUILD_DIR" +echo "🏃 Deploying $INPUT_BUILD_DIR directory to $INPUT_TARGET_BRANCH branch" +cd "$INPUT_BUILD_DIR" git init git config user.name "${GITHUB_ACTOR}" git config user.email "${GITHUB_ACTOR}@users.noreply.github.com" git add . git commit --allow-empty -m 'Deploy to GitHub pages' -git push --force --quiet https://${GITHUB_PAT:-"x-access-token:$GITHUB_TOKEN"}@github.com/${GITHUB_REPOSITORY}.git master:$TARGET_BRANCH +git push --force --quiet https://${GITHUB_PAT:-"x-access-token:$GITHUB_TOKEN"}@github.com/${GITHUB_REPOSITORY}.git master:${INPUT_TARGET_BRANCH} rm -rf .git cd "$GITHUB_WORKSPACE" -echo "🎉 Content of $BUILD_DIR has been deployed to GitHub Pages." +echo "🎉 Content of $INPUT_BUILD_DIR has been deployed to GitHub Pages."