Skip to content

Commit

Permalink
feat: make ssh-private-key optional
Browse files Browse the repository at this point in the history
  • Loading branch information
hussainweb committed Jan 15, 2022
1 parent e1725c0 commit 78bb8b2
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ The project ID on platform.sh. You can find this using the CLI or the web consol

A token to access platform.sh API. See instructions on [platform.sh docs](https://docs.platform.sh/development/cli/api-tokens.html).

### `ssh-private-key`
### `ssh-private-key` (optional)

Apart from the token, the action also needs a private key to use to be able to push via git (the CLI uses git internally). Create a specialized key used _only_ for deployment and use Github secrets to keep your key safe.
The platform.sh CLI generates a temporary certificate for use for deployment. However, you may still choose to provide a private key that lets you push via git. Create a specialized key used _only_ for deployment and use Github secrets to keep your key safe.

### `php-version`

Expand All @@ -32,5 +32,5 @@ with:
project-id: ${{ secrets.PlatformProjectId }}
cli-token: ${{ secrets.PlatformCliToken }}
ssh-private-key: ${{ secrets.PlatformSshKey }}
php-version: 7.4
php-version: 8.1
```
2 changes: 1 addition & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ inputs:
required: true
ssh-private-key:
description: 'SSH key to access the git repository on platform.sh'
required: true
required: false
php-version:
description: 'PHP version to setup for the CLI'
required: true
Expand Down
6 changes: 6 additions & 0 deletions deploy.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
#!/usr/bin/env bash

# Set up the private key if we have one.
if [[ -n "$SSH_PRIVATE_KEY" ]]; then
eval $(ssh-agent -s)
echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add - > /dev/null
fi

# Copy known hosts into the SSH config.
mkdir -p ~/.ssh && chmod 0700 ~/.ssh
cat ${GITHUB_ACTION_PATH}/known_hosts >> ~/.ssh/known_hosts
Expand Down

0 comments on commit 78bb8b2

Please sign in to comment.