diff --git a/.github/workflows/verify-on-container.yml b/.github/workflows/verify-on-container.yml new file mode 100644 index 0000000..9765d00 --- /dev/null +++ b/.github/workflows/verify-on-container.yml @@ -0,0 +1,28 @@ +# https://help.github.com/en/articles/workflow-syntax-for-github-actions + +name: Docker container on Ubuntu 20.04 + +on: +- push + +jobs: + ssh: + name: Connect to github.com + runs-on: ubuntu-20.04 + container: ubuntu:20.04 + steps: + - name: Install packages + run: | + apt update + apt -y install openssh-client git + - name: Checkout source codes + uses: actions/checkout@v2 + - name: Install SSH key + uses: ./. + with: + key: ${{ secrets.SSH_KEY }} + known_hosts: ${{ secrets.KNOWN_HOSTS }} + - name: print created files + run: ls -l /root/.ssh + - name: git clone through SSH + run: git clone git@github.com:shimataro/ssh-key-action.git tmp diff --git a/CHANGELOG.md b/CHANGELOG.md index 5389ad2..b65bb09 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ## [Unreleased] +### Added + +* Support Docker container (thanks [@kujaomega](https://github.com/kujaomega)) + ### Changed * Bundle dependencies (thanks [@tats-u](https://github.com/tats-u)) diff --git a/README.md b/README.md index 18bbd87..818d3b0 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,7 @@ [![Ubuntu 20.04][image-verify-ubuntu-2004]][link-verify-ubuntu-2004] [![Ubuntu 18.04][image-verify-ubuntu-1804]][link-verify-ubuntu-1804] [![Ubuntu 16.04][image-verify-ubuntu-1604]][link-verify-ubuntu-1604] +[![Docker container][image-verify-docker-container]][link-verify-docker-container] [![Release][image-release]][link-release] [![License][image-license]][link-license] [![Stars][image-stars]][link-stars] @@ -144,6 +145,8 @@ See [CHANGELOG.md](CHANGELOG.md). [link-verify-ubuntu-1804]: https://github.com/shimataro/ssh-key-action/actions?query=workflow%3A%22Ubuntu+18.04%22 [image-verify-ubuntu-1604]: https://github.com/shimataro/ssh-key-action/workflows/Ubuntu%2016.04/badge.svg?event=push&branch=v2 [link-verify-ubuntu-1604]: https://github.com/shimataro/ssh-key-action/actions?query=workflow%3A%22Ubuntu+16.04%22 +[image-verify-docker-container]: https://github.com/shimataro/ssh-key-action/workflows/Docker%20container%20on%20Ubuntu%2020.04/badge.svg?event=push&branch=v2 +[link-verify-docker-container]: https://github.com/shimataro/ssh-key-action/actions?query=workflow%3A%22Docker+container+on+Ubuntu+20.04%22 [image-release]: https://img.shields.io/github/release/shimataro/ssh-key-action.svg [link-release]: https://github.com/shimataro/ssh-key-action/releases [image-license]: https://img.shields.io/github/license/shimataro/ssh-key-action.svg diff --git a/lib/index.js b/lib/index.js index 0fe2f6d..3a2345a 100644 --- a/lib/index.js +++ b/lib/index.js @@ -485,6 +485,10 @@ function getHomeDirectory() { if (home === undefined) { throw Error(`${homeEnv} is not defined`); } + if (home === "/github/home") { + // Docker container + return "/root"; + } return home; } /** diff --git a/src/main.ts b/src/main.ts index 4333884..b39d10c 100644 --- a/src/main.ts +++ b/src/main.ts @@ -84,6 +84,12 @@ function getHomeDirectory(): string throw Error(`${homeEnv} is not defined`); } + if(home === "/github/home") + { + // Docker container + return "/root"; + } + return home; }