Skip to content

Commit b398fe5

Browse files
author
Greg Bowler
committed
wip: initial code and notes
1 parent bbdd8dd commit b398fe5

File tree

3 files changed

+65
-3
lines changed

3 files changed

+65
-3
lines changed

README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
Deploy your application using SSH
2-
=================================
1+
Deploy your application to servers or containers
2+
================================================
3+
4+
> **THIS IS CURRENTLY WORK IN PROGRESS** - once v1 is released there will be no more major changes.
35
46
After a successful test run, this action can copy the project's files via SSH to another server, a remote Docker container, or into a fresh server.
57

@@ -31,5 +33,5 @@ jobs:
3133
with:
3234
hostname: deploy.example.com
3335
user: webdeploy
34-
copy_to: /var/www/example.com
36+
path: /var/www/example.com
3537
```

action.yml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: Deploy (php-actions)
2+
description: Deploy your application to servers or containers
3+
4+
inputs:
5+
hostname:
6+
description: The hostname of the remote server to SSH to
7+
required: true
8+
9+
port:
10+
description: The port of the remote server to SSH to
11+
required: true
12+
default: "22"
13+
14+
user:
15+
description: The SSH user to use for deployment
16+
required: true
17+
default: "deploy"
18+
19+
path:
20+
description: Absolute path on the remote server to deploy into
21+
required: true
22+
default: "/app"
23+
24+
transfer_path:
25+
description: Absolute path on the remote server to use for the transfer
26+
required: true
27+
default: "/tmp/php-actions--deploy/"
28+
29+
runs:
30+
using: "composite"
31+
steps:
32+
- env:
33+
ACTION_TOKEN: ${{ github.token }}
34+
ACTION_HOSTNAME: ${{ inputs.hostname }}
35+
ACTION_PORT: ${{ inputs.port }}
36+
ACTION_USER: ${{ inputs.user }}
37+
ACTION_PATH: ${{ inputs.path }}
38+
ACTION_TRANSFER_PATH: ${{ inputs.transfer_path }}
39+
id: deploy_run
40+
run: ${{ github.action_path }}/deploy-action.bash
41+
shell: bash
42+
43+
branding:
44+
icon: "upload-cloud"
45+
color: "purple"

deploy-action.bash

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/bash
2+
set -e
3+
full_transfer_path="$ACTION_TRANSFER_PATH/$GITHUB_SHA"
4+
tar -czf - "$GITHUB_WORKSPACE" | \
5+
ssh -p "$ACTION_PORT" "$ACTION_USER"@"$ACTION_HOSTNAME" \
6+
"mkdir -p $full_transfer_path && cd $full_transfer_path && tar -xzvf -"
7+
8+
# TODO:
9+
# This should copy the files to the server.
10+
# Documentation is needed for getting SSH keys set up as secrets.
11+
# The transferred directory might be full of crap directories - can tar convert the path to relative to the $GITHUB_WORKSPACE?
12+
# Once transferred, what's the best way to switch the current $ACTION_PATH with the newly-deployed?
13+
# It's probable that the newly-created directory, once moved in place, will require symlinks adding to mount points (for external volumes)... how should this be handled?
14+
# On that same note, there will be certain deploy-specific config files needing putting in place... in real apps this will be a branch name database schema, but we could just put the branch name in the config.development.ini and echo it in PHP to prove that it's working...
15+
# For dev servers, there needs to be a way to deploy into a container with branch name, and for nginx to automatically know what to do with branchname.dev.example.com

0 commit comments

Comments
 (0)