From 5f9c65156dfae197b714738d1d6ca3c55a212e22 Mon Sep 17 00:00:00 2001 From: Jerry Ma Date: Mon, 30 Aug 2021 15:15:34 +0800 Subject: [PATCH] Create action-deploy.sh --- action-deploy.sh | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 action-deploy.sh diff --git a/action-deploy.sh b/action-deploy.sh new file mode 100644 index 00000000..66eb0b34 --- /dev/null +++ b/action-deploy.sh @@ -0,0 +1,29 @@ +#!/usr/bin/env bash + +if [ -n "${GITHUB_TOKEN}" ]; then + print_info "setup with GITHUB_TOKEN" + remote_repo="https://x-access-token:${GITHUB_TOKEN}@${GITHUB_DOMAIN:-"github.com"}/${GITHUB_REPOSITORY}.git" +elif [ -n "${PERSONAL_TOKEN}" ]; then + print_info "setup with PERSONAL_TOKEN" + remote_repo="https://x-access-token:${PERSONAL_TOKEN}@${GITHUB_DOMAIN:-"github.com"}/${GITHUB_REPOSITORY}.git" +fi + +if ! git config --get user.name; then + git config --global user.name "${GITHUB_ACTOR}" +fi + +if ! git config --get user.email; then + git config --global user.email "${GITHUB_ACTOR}@users.noreply.${GITHUB_DOMAIN:-"github.com"}" +fi + +cd dist + +git init -b deploy + +git add . + +git commit -m "automatic deployment" + +git remote add origin "${remote_repo}" + +git push -u origin deploy --force