Skip to content

Commit

Permalink
Merge pull request #3 from dawidd6/directory
Browse files Browse the repository at this point in the history
Directory
  • Loading branch information
dawidd6 authored Mar 24, 2020
2 parents ca781d9 + c94ab57 commit f13d1bd
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 1 deletion.
3 changes: 2 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ jobs:
--link host \
-v $PWD:/wd \
-w /wd \
-e INPUT_PLAYBOOK=playbook.yml \
-e INPUT_PLAYBOOK="playbook.yml" \
-e INPUT_DIRECTORY="./" \
-e INPUT_KEY="${{secrets.SSH_PRIVATE_KEY}}" \
-e INPUT_OPTIONS="--inventory hosts --limit remote" \
action
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ An action that executes given Ansible playbook on selected hosts.
uses: dawidd6/action-ansible-playbook@master
with:
playbook: deploy.yml
directory: ./
key: ${{secrets.SSH_PRIVATE_KEY}}
options: |
--inventory hosts
Expand Down
3 changes: 3 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ inputs:
playbook:
description: Ansible playbook filepath
required: true
directory:
description: Root directory of Ansible project (defaults to current)
required: false
key:
description: SSH private key used to connect to the host
required: true
Expand Down
5 changes: 5 additions & 0 deletions main.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
set -e

playbook="$INPUT_PLAYBOOK"
directory="$INPUT_DIRECTORY"
key="$INPUT_KEY"
options="$INPUT_OPTIONS"

Expand All @@ -16,6 +17,10 @@ if test -z "$key"; then
exit 1
fi

if test -n "$directory"; then
cd "$directory"
fi

mkdir -p "$HOME/.ssh"
echo "$key" > "$HOME/.ssh/id_rsa"
chmod 600 "$HOME/.ssh/id_rsa"
Expand Down

0 comments on commit f13d1bd

Please sign in to comment.