diff --git a/README.md b/README.md index 75c0367..c6bdabc 100644 --- a/README.md +++ b/README.md @@ -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` @@ -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 ``` diff --git a/action.yml b/action.yml index 5cbd523..ae474bf 100644 --- a/action.yml +++ b/action.yml @@ -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 diff --git a/deploy.sh b/deploy.sh index 39c84cb..c5198d2 100755 --- a/deploy.sh +++ b/deploy.sh @@ -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