Skip to content

Commit

Permalink
use curl
Browse files Browse the repository at this point in the history
  • Loading branch information
tmshkr committed Dec 4, 2023
1 parent 3e0f35d commit 6b526ad
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 8 deletions.
16 changes: 8 additions & 8 deletions .github/workflows/test-server.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 "<h1>hello world</h1>" > index.html && npx -y serve
39 changes: 39 additions & 0 deletions test/run-ssh-client-workflow.js
Original file line number Diff line number Diff line change
@@ -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;
}
}
);

0 comments on commit 6b526ad

Please sign in to comment.