From 6b526adc2c77d95527f353fc8930c6248a318b42 Mon Sep 17 00:00:00 2001 From: Tim Shaker Date: Mon, 4 Dec 2023 11:14:02 -0800 Subject: [PATCH] use curl --- .github/workflows/test-server.yml | 16 ++++++------- test/run-ssh-client-workflow.js | 39 +++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+), 8 deletions(-) create mode 100755 test/run-ssh-client-workflow.js diff --git a/.github/workflows/test-server.yml b/.github/workflows/test-server.yml index 1dc1574..1342ad4 100644 --- a/.github/workflows/test-server.yml +++ b/.github/workflows/test-server.yml @@ -14,14 +14,14 @@ jobs: NGROK_AUTHTOKEN: ${{ secrets.NGROK_AUTHTOKEN }} NGROK_CONFIG_FILE: "test/ngrok.yml" SSH_CLIENT_PUBLIC_KEY: ${{ vars.SSH_PUBLIC_KEY }} - - run: | - gh workflow run "test client" \ - -f NGROK_TUNNELS='${{ steps.ngrok-ssh.outputs.NGROK_TUNNELS }}' \ - -f SSH_HOSTNAME=${{ steps.ngrok-ssh.outputs.SSH_HOSTNAME }} \ - -f SSH_USER=${{ steps.ngrok-ssh.outputs.SSH_USER }} \ - -f SSH_PORT=${{ steps.ngrok-ssh.outputs.SSH_PORT }} \ - -f SSH_HOST_PUBLIC_KEY="${{ steps.ngrok-ssh.outputs.SSH_HOST_PUBLIC_KEY }}" \ - --ref ${{ github.ref }} + - name: Start SSH client workflow + run: ./test/run-ssh-client-workflow.js env: + NGROK_TUNNELS: ${{ steps.ngrok-ssh.outputs.NGROK_TUNNELS }} + SSH_HOSTNAME: ${{ steps.ngrok-ssh.outputs.SSH_HOSTNAME }} + SSH_USER: ${{ steps.ngrok-ssh.outputs.SSH_USER }} + SSH_PORT: ${{ steps.ngrok-ssh.outputs.SSH_PORT }} + SSH_HOST_PUBLIC_KEY: ${{ steps.ngrok-ssh.outputs.SSH_HOST_PUBLIC_KEY }} + REF: ${{ github.ref }} GH_TOKEN: ${{ github.token }} - run: echo "

hello world

" > index.html && npx -y serve diff --git a/test/run-ssh-client-workflow.js b/test/run-ssh-client-workflow.js new file mode 100755 index 0000000..089feb1 --- /dev/null +++ b/test/run-ssh-client-workflow.js @@ -0,0 +1,39 @@ +#!/bin/env node + +const { exec } = require("child_process"); +const { + GH_TOKEN, + NGROK_TUNNELS, + SSH_HOSTNAME, + SSH_USER, + SSH_PORT, + SSH_HOST_PUBLIC_KEY, + REF, +} = process.env; + +exec( + `curl -L \ + -X POST \ + -H "Accept: application/vnd.github+json" \ + -H "Authorization: Bearer ${GH_TOKEN}" \ + -H "X-GitHub-Api-Version: 2022-11-28" \ + https://api.github.com/repos/tmshkr/ngrok-ssh/actions/workflows/test-client.yml/dispatches \ + -d '${JSON.stringify({ + ref: REF, + inputs: { + NGROK_TUNNELS, + SSH_HOSTNAME, + SSH_USER, + SSH_PORT, + SSH_HOST_PUBLIC_KEY, + }, + })}' +`, + (err, stdout, stderr) => { + console.log(stdout); + console.log(stderr); + if (err) { + throw err; + } + } +);