From 6ab3bd42662db18f4d557fe875492f99ad010649 Mon Sep 17 00:00:00 2001 From: fscarmen <62703343+fscarmen@users.noreply.github.com> Date: Fri, 24 Mar 2023 08:35:05 +0800 Subject: [PATCH] Create sync_client.yml --- .github/workflows/sync_client.yml | 60 +++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 .github/workflows/sync_client.yml diff --git a/.github/workflows/sync_client.yml b/.github/workflows/sync_client.yml new file mode 100644 index 0000000..a5fffe5 --- /dev/null +++ b/.github/workflows/sync_client.yml @@ -0,0 +1,60 @@ +name: Sync CloudFlare Client + +on: + workflow_dispatch: + schedule: + - cron: '18 2 * * *' + +jobs: + WireGuard-go: + + name: Sync Client to the latest + + runs-on: ubuntu-20.04 + + env: + USERNAME: ${{ secrets.GH_USERNAME }} + EMAIL: ${{ secrets.GH_EMAIL }} + + steps: + - name: Checkout code + uses: actions/checkout@v3.3.0 + with: + fetch-depth: 0 + + - name: Check the official latest version of Client + run: | + NOW=$(wget -qO- "https://api.github.com/repos/${{ env.USERNAME }}/warp/releases" | grep "tag_name" | grep "CloudFlare" | head -n 1 | sed "s/.*_v\(.\{1,\}\)\".*/\1/g") + LATEST=$(wget -qO- "https://pkg.cloudflareclient.com/packages/cloudflare-warp" | grep "release-row" | awk -F '' {'print $1'} | awk -F '' {'print $2'}) + + Operating_System=("CentOS 8" "Debian Bullseye" "Debian Buster" "Debian Stretch" "Ubuntu Jammy" "Ubuntu Focal" "Ubuntu Bionic" "Ubuntu Xenial") + System_Rename=("CentOS_8.rpm" "Debian_11.deb" "Debian_10.deb" "Debian_9.deb" "Ubuntu_22.04.deb" "Ubuntu_20.04.deb" "Ubuntu_18.04.deb" "Ubuntu_16.04.deb") + + if [ "$LATEST_VERSION" != "$NOW_VERSION" ]; then + [ ! -d ${GITHUB_WORKSPACE}/Client ] && mkdir -p ${GITHUB_WORKSPACE}/Client + for ((i=0; i<${#Operating_System[@]}; i++)); do + File_Path=$(wget -qO- https://pkg.cloudflareclient.com/packages/cloudflare-warp | grep 'release-row' | awk -F "${Operating_System[i]}" {'print $2'} | awk -F 'Download' {'print $1'} | awk -F \" {'print $2'}) + Download_URL="https://pkg.cloudflareclient.com$File_Path" + wget -O ${GITHUB_WORKSPACE}/Client/Client_${System_Rename[i]} $Download_URL + done + + echo "VERSION=$LATEST" >> $GITHUB_ENV + echo "DIST=${GITHUB_WORKSPACE}/Client" >> $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 Client to V${{ env.VERSION }} by Github Actions, $(date "+%Y/%m/%d %H:%M:%S")" + git push + rm -f ${{ env.DIST }}/README.md + + - name: Release binaries + uses: softprops/action-gh-release@v1 + if: ${{ env.VERSION != '' }} + with: + tag_name: CloudFlare_Client_v${{ env.VERSION }} + files: ${{ env.DIST }}/*