Skip to content

Commit 78bb8b2

Browse files
committed
feat: make ssh-private-key optional
1 parent e1725c0 commit 78bb8b2

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ The project ID on platform.sh. You can find this using the CLI or the web consol
1212

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

15-
### `ssh-private-key`
15+
### `ssh-private-key` (optional)
1616

17-
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.
17+
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.
1818

1919
### `php-version`
2020

@@ -32,5 +32,5 @@ with:
3232
project-id: ${{ secrets.PlatformProjectId }}
3333
cli-token: ${{ secrets.PlatformCliToken }}
3434
ssh-private-key: ${{ secrets.PlatformSshKey }}
35-
php-version: 7.4
35+
php-version: 8.1
3636
```

action.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ inputs:
99
required: true
1010
ssh-private-key:
1111
description: 'SSH key to access the git repository on platform.sh'
12-
required: true
12+
required: false
1313
php-version:
1414
description: 'PHP version to setup for the CLI'
1515
required: true

deploy.sh

+6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
#!/usr/bin/env bash
22

3+
# Set up the private key if we have one.
4+
if [[ -n "$SSH_PRIVATE_KEY" ]]; then
5+
eval $(ssh-agent -s)
6+
echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add - > /dev/null
7+
fi
8+
39
# Copy known hosts into the SSH config.
410
mkdir -p ~/.ssh && chmod 0700 ~/.ssh
511
cat ${GITHUB_ACTION_PATH}/known_hosts >> ~/.ssh/known_hosts

0 commit comments

Comments
 (0)