Repository: csexton/debugger-action Branch: master Commit: 0de54ee5b983 Files: 8 Total size: 6.0 KB Directory structure: gitextract_hnho3f1d/ ├── .eslintrc.json ├── .gitignore ├── LICENSE ├── README.md ├── action.js ├── action.yml ├── package.json └── script.sh ================================================ FILE CONTENTS ================================================ ================================================ FILE: .eslintrc.json ================================================ { "env": { "commonjs": true, "es6": true, "node": true }, "extends": "eslint:recommended", "globals": { "Atomics": "readonly", "SharedArrayBuffer": "readonly" }, "parserOptions": { "ecmaVersion": 2018 }, "rules": { } } ================================================ FILE: .gitignore ================================================ # comment this out distribution branches #node_modules/ # Editors .vscode # Logs logs *.log npm-debug.log* yarn-debug.log* yarn-error.log* # Runtime data pids *.pid *.seed *.pid.lock # Directory for instrumented libs generated by jscoverage/JSCover lib-cov # Coverage directory used by tools like istanbul coverage # nyc test coverage .nyc_output # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) .grunt # Bower dependency directory (https://bower.io/) bower_components # node-waf configuration .lock-wscript # Compiled binary addons (https://nodejs.org/api/addons.html) build/Release # Other Dependency directories jspm_packages/ # TypeScript v1 declaration files typings/ # Optional npm cache directory .npm # Optional eslint cache .eslintcache # Optional REPL history .node_repl_history # Output of 'npm pack' *.tgz # Yarn Integrity file .yarn-integrity # dotenv environment variables file .env # next.js build output .next ================================================ FILE: LICENSE ================================================ MIT License Copyright (c) 2019 GitHub Actions Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ================================================ FILE: README.md ================================================ # Action Debugger Interactive debugger for GitHub Actions ## Usage ``` steps: - name: Setup Debug Session uses: csexton/debugger-action@master ``` In the log for the action you will see: ``` Running tmate... To connect to this session copy-n-paste the following into a terminal: ssh redactedMxoJ0pXmjredacted@nyc1.tmate.io ``` Simply follow the instructions and copy the ssh command into your terminal to create an ssh connection the running instance. The session will close immedeatly after closing the ssh connection to the running instance. There is a global timeout after 15 minutes. This will close any open ssh sessions. To prevent the session from being terminated run: ``` touch /tmp/keepalive ``` ## Acknowledgments * [tmate.io](https://tmate.io) * Max Schmitt's [action-tmate](https://github.com/mxschmitt/action-tmate) ### License The action and associated scripts and documentation in this project are released under the MIT License. ================================================ FILE: action.js ================================================ const core = require('@actions/core'); function run() { try { // This is just a thin wrapper around bash const script = require('path').resolve(__dirname, 'script.sh'); console.log(script); var child = require('child_process').execFile(script); child.stdout.on('data', (data) => { console.log(data.toString()); }); child.on('close', (code) => { console.log(`child process exited with code ${code}`); process.exit(code); }); } catch (error) { core.setFailed(error.message); } } run() ================================================ FILE: action.yml ================================================ name: 'Debugger' description: 'Interactive debugger for GitHub Action with tmate.io' runs: using: 'node12' main: 'action.js' branding: icon: 'terminal' color: 'green' ================================================ FILE: package.json ================================================ { "name": "javascript-action", "version": "1.0.0", "description": "JavaScript Action Template", "main": "index.js", "scripts": { "lint": "eslint index.js", "test": "eslint index.js && jest" }, "repository": { "type": "git", "url": "git+https://github.com/actions/javascript-action.git" }, "keywords": [ "GitHub", "Actions", "JavaScript" ], "author": "GitHub", "license": "MIT", "bugs": { "url": "https://github.com/actions/javascript-action/issues" }, "homepage": "https://github.com/actions/javascript-action#readme", "dependencies": { "@actions/core": "^1.1.1" }, "devDependencies": { "eslint": "^6.3.0", "jest": "^24.9.0" } } ================================================ FILE: script.sh ================================================ #!/bin/bash set -e if [[ ! -z "$SKIP_DEBUGGER" ]]; then echo "Skipping debugger because SKIP_DEBUGGER enviroment variable is set" exit fi # Install tmate on macOS or Ubuntu echo Setting up tmate... if [ -x "$(command -v brew)" ]; then brew install tmate > /tmp/brew.log fi if [ -x "$(command -v apt-get)" ]; then sudo apt-get install -y tmate openssh-client > /tmp/apt-get.log fi # Generate ssh key if needed [ -e ~/.ssh/id_rsa ] || ssh-keygen -t rsa -f ~/.ssh/id_rsa -q -N "" # Run deamonized tmate echo Running tmate... tmate -S /tmp/tmate.sock new-session -d tmate -S /tmp/tmate.sock wait tmate-ready # Print connection info echo ________________________________________________________________________________ echo echo To connect to this session copy-n-paste the following into a terminal: tmate -S /tmp/tmate.sock display -p '#{tmate_ssh}' echo After connecting you can run 'touch /tmp/keepalive' to disable the 15m timeout if [[ ! -z "$SLACK_WEBHOOK_URL" ]]; then MSG=$(tmate -S /tmp/tmate.sock display -p '#{tmate_ssh}') curl -X POST -H 'Content-type: application/json' --data "{\"text\":\"\`$MSG\`\"}" $SLACK_WEBHOOK_URL fi # Wait for connection to close or timeout in 15 min timeout=$((15*60)) while [ -S /tmp/tmate.sock ]; do sleep 1 timeout=$(($timeout-1)) if [ ! -f /tmp/keepalive ]; then if (( timeout < 0 )); then echo Waiting on tmate connection timed out! exit 1 fi fi done