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