From de234b3d8c4c932138787c346fa024b539f98ac9 Mon Sep 17 00:00:00 2001 From: name Date: Fri, 4 Feb 2022 00:29:37 +0800 Subject: [PATCH] fix not login to gh --- .github/workflows/destversion.yml | 10 +++++----- scripts/destVersionRelease.sh | 16 ++++++++++++++-- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/.github/workflows/destversion.yml b/.github/workflows/destversion.yml index 0e24a15..92e8fdc 100644 --- a/.github/workflows/destversion.yml +++ b/.github/workflows/destversion.yml @@ -15,9 +15,9 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - # - name: Config git - # run: git config --global user.email "name@gmail.com"&&git config --global user.name "name" - - name: Check new version and push - run: bash -x ./scripts/destVersionRelease.sh ${{ github.event.inputs.download_link }} - name: Test Github Action Server Time - run: bash -x echo `date` \ No newline at end of file + run: bash -x echo `date` + - name: Check new version and push + env: + GHTOKEN: ${{ secrets.GHTOKEN }} + run: bash -x ./scripts/destVersionRelease.sh ${{ github.event.inputs.download_link }} diff --git a/scripts/destVersionRelease.sh b/scripts/destVersionRelease.sh index c52fb60..8eac4c4 100755 --- a/scripts/destVersionRelease.sh +++ b/scripts/destVersionRelease.sh @@ -11,7 +11,7 @@ if [ -z "$1" ]; then download_link="https://dldir1.qq.com/weixin/Windows/WeChatSetup.exe" fi -function install_depends () { +function install_depends() { printf "#%.0s" {1..60} echo echo -e "## \033[1;33mInstalling 7zip, shasum, wget, curl, git\033[0m" @@ -20,6 +20,16 @@ function install_depends () { apt install -y p7zip-full p7zip-rar libdigest-sha-perl wget curl git } +function login_gh() { + echo $GHTOKEN > WeChatSetup/temp/GHTOKEN + gh auth login --with-token < WeChatSetup/temp/GHTOKEN + if [ "$?" -ne 0 ]; then + >&2 echo -e "\033[1;31mLogin Failed, please check your network or token!\033[0m" + clean_data 1 + fi + rm -rfv WeChatSetup/temp/GHTOKEN +} + function download_wechat() { printf "#%.0s" {1..60} echo @@ -74,8 +84,9 @@ function clean_data() { } function main() { - rm -rfv WeChatSetup/* + # rm -rfv WeChatSetup/* mkdir -p ${temp_path}/temp + login_gh ## https://github.com/actions/virtual-environments/blob/main/images/linux/Ubuntu2004-Readme.md # install_depends download_wechat @@ -92,6 +103,7 @@ function main() { prepare_commit gh release create v$dest_version ./WeChatSetup/$dest_version/WeChatSetup-$dest_version.exe -F ./WeChatSetup/$dest_version/WeChatSetup-$dest_version.exe.sha256 -t "Wechat v$dest_version" + gh auth logout clean_data 0 }