Process SSH Connection
ActionsTags
(2)This action processes SSH connection details based on tag or branch name. It helps standardize environment variable names for SSH connections.
- Extract environment suffix from ref or use direct input
- Convert environment-specific variable names to standard outputs
- Automatically process SSH key line breaks
- Support for multiple environments (prod, staging, etc.)
| Input | Description | Required | Default |
|---|---|---|---|
suffix |
Direct suffix value to use (takes precedence over ref) | false | '' |
ref |
Reference string to process | false | ${{ github.ref }} |
suffix_regex |
Regular expression to extract suffix from ref | false | 'refs/(tags|heads)/.*-(.+)' |
suffix_group |
Group number in regex that contains the suffix | false | '2' |
| Output | Description |
|---|---|
host |
Selected SSH host variable name |
username |
Selected SSH username variable name |
port |
Selected SSH port variable name |
key |
SSH key with processed line breaks |
environment |
Selected environment (lowercase suffix) |
environment_upper |
Selected environment in uppercase |
For each environment (suffix), you need to set these environment variables:
SSH_HOST_{SUFFIX}SSH_USERNAME_{SUFFIX}SSH_PORT_{SUFFIX}SSH_KEY_{SUFFIX}
Where {SUFFIX} is the uppercase version of your environment suffix.
- uses: ilaipi-freedom/process-ssh-connection-action@v1.0.5
with:
suffix: 'prod'- uses: ilaipi-freedom/process-ssh-connection-action@v1.0.5
with:
ref: 'refs/tags/release-prod'
suffix_regex: 'refs/(tags|heads)/.*-(.+)'
suffix_group: '2'name: Deploy
on:
push:
tags:
- '*-prod'
- '*-staging'
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
# Load environment variables from .env file
- name: Load Environment Variables
uses: ilaipi-freedom/load-env-action@v1.0.2
- name: Process SSH Connection
id: ssh
uses: ilaipi-freedom/process-ssh-connection-action@v1.0.5
- name: Use SSH Connection
uses: appleboy/ssh-action@v1.0.0
with:
host: ${{ env[steps.ssh.outputs.host] }}
username: ${{ env[steps.ssh.outputs.username] }}
port: ${{ env[steps.ssh.outputs.port] }}
key: ${{ steps.ssh.outputs.key }}
script: |
echo "Connected to ${{ steps.ssh.outputs.environment }} environment!"- The action will automatically convert the suffix to uppercase when constructing environment variable names.
- SSH key line breaks (
\n) are automatically processed. - Make sure all required environment variables are set before using this action.
- The action outputs both lowercase environment name (
environment) and uppercase version (environment_upper) for flexibility.
Process SSH Connection is not certified by GitHub. It is provided by a third-party and is governed by separate terms of service, privacy policy, and support documentation.