From 9c7591611a8c59b2cdb5759ab0b015128e35abb8 Mon Sep 17 00:00:00 2001 From: fscarmen <62703343+fscarmen@users.noreply.github.com> Date: Thu, 25 Jan 2024 06:16:33 +0000 Subject: [PATCH] Test after release. --- .github/workflows/test.yml | 34 ++++++++++++++++++ README.md | 14 +++++++- action.yml | 70 +++++++++++++++++++++++++++----------- 3 files changed, 98 insertions(+), 20 deletions(-) create mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..35cbc5c --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,34 @@ +name: "Test" + +on: + workflow_dispatch: + release: + types: [created] + tags: + - 'v*' + + +jobs: + client-by-default: + runs-on: ubuntu-latest + name: client warp+doh mode by default + steps: + - uses: fscarmen/warp-on-actions@v1.0 + + client: + runs-on: ubuntu-latest + name: client warp+doh mode + steps: + - name: Set up WARP with client + uses: fscarmen/warp-on-actions@v1.0 + with: + mode: client + + wireguard: + runs-on: ubuntu-latest + name: wireguard mode + steps: + - name: Set up WARP with wireguard + uses: fscarmen/warp-on-actions@v1.0 + with: + mode: wireguard \ No newline at end of file diff --git a/README.md b/README.md index b8f2e5f..cf56ae8 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,18 @@ * * * Usage: +* client warp+doh mode ``` - - uses: fscarmen/warp-on-actions@v1 + - name: Set up WARP + uses: fscarmen/warp-on-actions@v1.0 + with: + mode: client # Optional, default ``` + +* wireguard +``` + - name: Set up WARP + uses: fscarmen/warp-on-actions@v1.0 + with: + mode: wireguard +``` \ No newline at end of file diff --git a/action.yml b/action.yml index 97f62ad..1b52c89 100644 --- a/action.yml +++ b/action.yml @@ -1,25 +1,57 @@ -name: 'Install Warp' +# action.yml +name: 'Install WARP' +author: 'fscarmen ' description: 'Install Cloudflare Warp on Github actions' +inputs: + mode: + description: 'Choose WARP mode: wireguard or client.' + required: false + default: 'client' + runs: using: composite steps: - - name: Install Warp - continue-on-error: true + - name: Install WARP run: | - sudo apt-get -y update - sudo apt-get -y install --no-install-recommends net-tools iproute2 openresolv dnsutils iptables wireguard-tools - echo "[Interface] - PrivateKey = cKE7LmCF61IhqqABGhvJ44jWXp8fKymcMAEVAzbDF2k= - Address = 172.16.0.2/32 - Address = fd01:5ca1:ab1e:823e:e094:eb1c:ff87:1fab/128 - DNS = 8.8.8.8,8.8.4.4 - MTU = 1280 - [Peer] - PublicKey = bmXOC+F1FxEMF9dyiK2H5/1SUtzH0JuVo51h2wPfgyo= - AllowedIPs = 0.0.0.0/0 - AllowedIPs = ::/0 - Endpoint = 162.159.193.10:2408" | sudo tee /etc/wireguard/wgcf.conf - sudo wg-quick up wgcf - sudo curl -s4m8 ip.sb - shell: bash + if [ "${{ inputs.mode }}" == 'client' ]; then + echo "WARP mode: client warp+doh." + sudo apt-get -y update + curl -fsSL https://pkg.cloudflareclient.com/pubkey.gpg | sudo gpg --yes --dearmor --output /usr/share/keyrings/cloudflare-warp-archive-keyring.gpg + echo "deb [arch=amd64 signed-by=/usr/share/keyrings/cloudflare-warp-archive-keyring.gpg] https://pkg.cloudflareclient.com/ $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/cloudflare-client.list + sudo apt-get update + sudo apt-get install -y cloudflare-warp + sudo warp-cli --accept-tos register + sudo warp-cli --accept-tos set-mode warp+doh + sudo warp-cli --accept-tos connect + + elif [ "${{ inputs.mode }}" == 'wireguard' ]; then + echo "WARP mode: wireguard." + sudo apt-get -y update + sudo apt-get -y install --no-install-recommends net-tools iproute2 openresolv dnsutils iptables wireguard-tools + LAN=$(ip route get 192.168.193.10 | grep -oP 'src \K\S+') + echo "[Interface] + PrivateKey = cKE7LmCF61IhqqABGhvJ44jWXp8fKymcMAEVAzbDF2k= + Address = 172.16.0.2/32 + Address = fd01:5ca1:ab1e:823e:e094:eb1c:ff87:1fab/128 + PostUp = ip -4 rule add from $LAN lookup main + PostDown = ip -4 rule delete from $LAN lookup main + DNS = 8.8.8.8,8.8.4.4 + MTU = 1280 + + [Peer] + PublicKey = bmXOC+F1FxEMF9dyiK2H5/1SUtzH0JuVo51h2wPfgyo= + AllowedIPs = 0.0.0.0/0 + AllowedIPs = ::/0 + Endpoint = 162.159.193.10:2408" | sed "s/^[ ]\+//g" | sudo tee /etc/wireguard/warp.conf + sudo wg-quick up warp + + else + echo -e "WARP mode: ${{ inputs.mode }}.\nYou can choose client or wireguard." + exit 1 + fi + + sleep 1 + sudo curl -s4m8 --retry 3 -A Mozilla https://api.ip.sb/geoip + + shell: bash \ No newline at end of file