From 33fa22084d3575b45b3f8b410d587388a7a148ea Mon Sep 17 00:00:00 2001 From: fscarmen <62703343+fscarmen@users.noreply.github.com> Date: Fri, 24 Mar 2023 09:54:12 +0800 Subject: [PATCH] Create sync_wgcf.yml --- .github/workflows/sync_wgcf.yml | 61 +++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 .github/workflows/sync_wgcf.yml diff --git a/.github/workflows/sync_wgcf.yml b/.github/workflows/sync_wgcf.yml new file mode 100644 index 0000000..f255513 --- /dev/null +++ b/.github/workflows/sync_wgcf.yml @@ -0,0 +1,61 @@ +name: Sync wgcf latest version + +on: + workflow_dispatch: + schedule: + - cron: '3 2 * * *' + +jobs: + build: + name: Sync wgcf latest version + runs-on: ubuntu-latest + env: + USERNAME: ${{ secrets.GH_USERNAME }} + EMAIL: ${{ secrets.GH_EMAIL }} + + steps: + - uses: actions/checkout@v3.4.0 + - name: Update wgcf to latest version + run: | + NOW=$(wget -qO- https://raw.githubusercontent.com/${{ env.USERNAME }}/warp/main/menu.sh | grep 'latest=${latest' | cut -d \' -f2) + LATEST=$(wget -qO- "https://api.github.com/repos/ViRb3/wgcf/releases/latest" | grep "tag_name" | head -n 1 | cut -d : -f2 | sed 's/[ \"v,]//g') + + if [ "$LATEST" != "$NOW" ]; then + [ ! -d ${GITHUB_WORKSPACE}/wgcf ] && mkdir -p ${GITHUB_WORKSPACE}/wgcf + PLATFORM=( "darwin_amd64" + "darwin_arm64" + "linux_386" + "linux_amd64" + "linux_arm64" + "linux_386" + "linux_s390x" + "windows_386.exe" + "windows_amd64.exe" + ) + + SCRIPTS=( "docker.sh" + "menu.sh" + "pc/mac.sh" + ) + + for i in "${PLATFORM[@]}"; do + wget -NP ${GITHUB_WORKSPACE}/wgcf/ https://github.com/ViRb3/wgcf/releases/download/v"$LATEST"/wgcf_"$LATEST"_"$i" + rm -f ${GITHUB_WORKSPACE}/wgcf/wgcf_"$NOW"_"$i" + done + + for j in "${SCRIPTS[@]}"; do + sed -i "s/$NOW/$LATEST/g" ${GITHUB_WORKSPACE}/$j + done + + echo "VERSION=$LATEST" >> $GITHUB_ENV + fi + + - name: Upload to REPO + if: ${{ env.VERSION != '' }} + run: | + git config --global user.email "${{ env.EMAIL }}" + git config --global user.name "${{ env.USERNAME }}" + git add . + git commit -m "Sync WGCF to V${{ env.VERSION }} by Github Actions, $(date "+%Y/%m/%d %H:%M:%S")" + git push +