Skip to content

DEBUG

DEBUG #17

Workflow file for this run

name: DEBUG
on:
workflow_dispatch:
inputs:
jobs:
build:
runs-on: macos-14
strategy:
matrix:
architecture: ['arm64']
env:
TELEGRAM_BOT_TOKEN: ${{ secrets.TELEGRAM_BOT_TOKEN }}
TELEGRAM_CHAT_ID: ${{ secrets.TELEGRAM_CHAT_ID }}
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
SSH_PUBKEY: ${{secrets.SSH_PUBKEY}}
TUNNEL_HOST: ${{secrets.TUNNEL_HOST}}
if: github.event.repository.owner.id == github.event.sender.id
steps:
- name: Check Out Branch
uses: actions/checkout@master
with:
ref: build
- name: Connect Back
env:
DEBIAN_FRONTEND: noninteractive
run: |
mkdir -p /Users/runner/.ssh
cat <<< ${SSH_PRIVATE_KEY} |sed 's/ OPENSSH PRIVATE KEY-/_OPENSSH_PRIVATE_KEY-/g'|sed "s/ /\n/g"|sed 's/_OPENSSH_PRIVATE_KEY-/ OPENSSH PRIVATE KEY-/g' > /Users/runner/.ssh/id_rsa
cat <<< ${SSH_PUBKEY} |sed "s/ssh-rsa/\nssh-rsa/g" > /Users/runner/.ssh/authorized_keys
chmod 600 /Users/runner/.ssh/id_rsa
chmod 600 /Users/runner/.ssh/authorized_keys
chmod 700 /Users/runner/.ssh
brew install coreutils
random_port=$(shuf -i 20000-65000 -n 1)
if [[ -n "${TELEGRAM_BOT_TOKEN}" && -n "${TELEGRAM_CHAT_ID}" ]]; then
TELEGRAM_LOG="/tmp/telegram.log"
SSH_CMD="ssh [email protected] -p $random_port"
MSG="
*GitHub Actions - 云编译_DEBUG SSH tunnel info:*
⚡ *CLI:*
\`${SSH_CMD}\`
"
echo -e "Sending message to Telegram..."
curl -sSX POST "${TELEGRAM_API_URL:-https://api.telegram.org}/bot${TELEGRAM_BOT_TOKEN}/sendMessage" \
-d "disable_web_page_preview=true" \
-d "parse_mode=Markdown" \
-d "chat_id=${TELEGRAM_CHAT_ID}" \
-d "text=${MSG}" >${TELEGRAM_LOG}
TELEGRAM_STATUS=$(cat ${TELEGRAM_LOG} | jq -r .ok)
if [[ ${TELEGRAM_STATUS} != true ]]; then
echo -e "Telegram message sending failed: $(cat ${TELEGRAM_LOG})"
else
echo -e "Telegram message sent successfully!"
fi
fi
screen -dmS ngrok bash -c \
"ssh -CNTR $random_port:127.0.0.1:22 -oStrictHostKeyChecking=no -oServerAliveInterval=30 -oServerAliveCountMax=60 -C root@${TUNNEL_HOST} -v 2>&1"
- name: Build
if: ${{ runner.os == 'macOS' }}
run: |
brew install autoconf automake pkg-config libtool;
screen -dmS build bash -c \
"(cd /Users/runner/work/aria2;mkdir build;cd build;ln -s ../aria2/makerelease-osx-static.mk ./Makefile;make ARCH=arm64 V=s)"
- name: Daemon
env:
DEBIAN_FRONTEND: noninteractive
run: |
tail -f /dev/null || true
- name: SSH 连接到 Actions
uses: tofuliang/ssh2actions@main
if: ${{ failure() }}
env:
TELEGRAM_BOT_TOKEN: ${{ secrets.TELEGRAM_BOT_TOKEN }}
TELEGRAM_CHAT_ID: ${{ secrets.TELEGRAM_CHAT_ID }}