Skip to content

Get A GITHUB VM

Get A GITHUB VM #232

name: Get A GITHUB VM
on:
watch:
types: [started]
push:
branches:
- main
repository_dispatch:
types: [run]
jobs:
run:
runs-on: ubuntu-latest
if: github.actor == github.event.repository.owner.login
steps:
- name: Print Env
env:
GITHUB: ${{ toJSON(github) }}
RUN_ID: ${{ github.run_id }}
RUN_NUMBER: ${{ github.run_number }}
run: |
echo $RUN_ID
echo $RUN_NUMBER
echo $GITHUB
- name: Install Dependency
run: |
sudo apt install zsh
sudo chmod g-w,o-w /usr/share/zsh /usr/share/zsh/vendor-completions
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" "" --unattended
- name: Install Lua
uses: leafo/gh-actions-lua@v8
- name: Install Luarocks
uses: leafo/gh-actions-luarocks@v4
- name: Setup Env
env:
KEY: ${{ secrets.KEY }}
run: |
printf "%s" "$KEY" > /tmp/ssh.key
chmod 600 /tmp/ssh.key
touch continue
- name: Tmate
env:
GIT_SSH_COMMAND: "ssh -i /tmp/ssh.key"
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
uses: mxschmitt/action-tmate@v3
with:
limit-access-to-actor: true
tmate-server-host: ${{ secrets.TMATE_SERVER_HOST }}
tmate-server-port: ${{ secrets.TMATE_SERVER_PORT }}
tmate-server-rsa-fingerprint: ${{ secrets.TMATE_SERVER_RSA_FINGERPRINT }}
tmate-server-ed25519-fingerprint: ${{ secrets.TMATE_SERVER_ED25519_FINGERPRINT }}
- id: GetTmateSSH
run: |
`ps --no-headers -o "args" -C tmate | awk '{print $1}'` -S /tmp/tmate.sock display -p '#{tmate_ssh}' | awk '{print $2}' | awk -F'@' '{print "<ssh://"$1";-nassh-args=--ssh-agent=eechpbnaifiimgajnomdipfaamobdfha@"$2"|go to ssh>"}' > /tmp/ssh_url
`ps --no-headers -o "args" -C tmate | awk '{print $1}'` -S /tmp/tmate.sock display -p '#{tmate_ssh}' > /tmp/TMATE_SSH
echo "::set-output name=ssh_url::$(cat /tmp/ssh_url)"
echo "::set-output name=ssh::$(cat /tmp/TMATE_SSH)"
- name: Slack Notification
uses: rtCamp/action-slack-notify@v2
env:
SLACK_WEBHOOK: ${{ secrets.SLACK_WEB_HOOK }}
SLACK_TITLE: Get A GITHUB VM
SLACK_MESSAGE: "${{join(steps.GetTmateSSH.outputs.*, '\n')}}"
- name: Wait tmate exit
run: |
while true; do pgrep tmate || break; sleep 5; done