Skip to content

Commit b7307c7

Browse files
committed
Merge branch 'develop' for v2.0.2
2 parents 01df8a0 + d5a0f34 commit b7307c7

File tree

3 files changed

+41
-8
lines changed

3 files changed

+41
-8
lines changed

README.md

+8-6
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
steps:
2828
- uses: actions/checkout@v2
2929
- name: Deploy
30-
uses: rtCamp/[email protected].0
30+
uses: rtCamp/[email protected].2
3131
env:
3232
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
3333
```
@@ -40,10 +40,12 @@ jobs:
4040

4141
This GitHub action's behavior can be customized using following environment variables:
4242

43-
Variable | Default | Possible Values | Purpose
44-
---------------|---------|-----------------------------|----------------------------------------------------
45-
`MU_PLUGINS_URL` | null | vip, any git repo url | If value is `vip`, then action will clone [VIP's MU plugins](https://github.com/Automattic/vip-mu-plugins-public) as `mu-plugins` folder. If you want to specifiy a non-VIP mu-plugins repo, you can provide a publicly accessible mu-plugins repo URL as the value.
46-
`WP_VERSION` | latest | Any valid WordPress version | If you specify a WordPress version, then that speicifc WordPress version will be downloaded, instead of latest WordPress version.
43+
Variable | Default | Possible Values | Purpose
44+
------------------|---------|-----------------------------|----------------------------------------------------
45+
`MU_PLUGINS_URL` | null | vip, any git repo url | If value is `vip`, then action will clone [VIP's MU plugins](https://github.com/Automattic/vip-mu-plugins-public) as `mu-plugins` folder. If you want to specifiy a non-VIP mu-plugins repo, you can provide a publicly accessible mu-plugins repo URL as the value.
46+
`WP_VERSION` | latest | Any valid WordPress version | If you specify a WordPress version, then that speicifc WordPress version will be downloaded, instead of latest WordPress version.
47+
`JUMPHOST_SERVER` | null | Hostname/IP address of the jumphost server | If the deployment server is not directly accessible, and needs a jumphost, then this method should be used. (Note: The `SSH_PRIVATE_KEY` env variable should have access to the jumphost as well as deployment server for this to work. Also, this method does not work with vault.)
48+
`SUBMODULE_DEPLOY_KEY` | null | Read access deploy key created in the submodule repo's deploy keys. | Only required for privated submodule repo. For now only one private submodule deploy key is allowed. All public submodules in repo will be fetched by default without the need of this env variable. (To create a deploy key go to: Settings > Deploy Keys > Add deploy key)
4749

4850

4951
## Server Setup
@@ -99,7 +101,7 @@ jobs:
99101
steps:
100102
- uses: actions/checkout@v2
101103
- name: Deploy
102-
uses: rtCamp/[email protected].0
104+
uses: rtCamp/[email protected].2
103105
env:
104106
VAULT_ADDR: ${{ secrets.VAULT_ADDR }}
105107
VAULT_TOKEN: ${{ secrets.VAULT_TOKEN }}

action.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ description: 'Deploy WordPress code to a server'
33
author: 'rtCamp'
44
runs:
55
using: 'docker'
6-
image: 'Dockerfile'
6+
image: 'docker://rtcamp/action-deploy-wordpress:v2.0.2'
77
branding:
88
icon: 'upload-cloud'
99
color: 'yellow'

main.sh

+32-1
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,22 @@ rsync -av "$hosts_file" /hosts.yml
66
cat /hosts.yml
77

88
# Check branch
9-
if [ "$GITHUB_REF" = "" ]; then
9+
if [[ "$GITHUB_REF" = "" ]]; then
1010
echo "\$GITHUB_REF is not set"
1111
exit 1
1212
fi
1313

14+
# Check for SSH key if jump host is defined
15+
if [[ ! -z "$JUMPHOST_SERVER" ]]; then
16+
17+
if [[ -z "$SSH_PRIVATE_KEY" ]]; then
18+
echo "Jump host configuration does not work with vault ssh signing."
19+
echo "SSH_PRIVATE_KEY secret needs to be added."
20+
echo "The SSH key should have access to the server as well as jumphost."
21+
exit 1
22+
fi
23+
fi
24+
1425
match=0
1526
for branch in $(cat "$hosts_file" | shyaml keys); do
1627
[[ "$GITHUB_REF" = "refs/heads/$branch" ]] && \
@@ -50,6 +61,10 @@ if [[ -n "$SSH_PRIVATE_KEY" ]]; then
5061
chmod 600 "$SSH_DIR/id_rsa"
5162
eval "$(ssh-agent -s)"
5263
ssh-add "$SSH_DIR/id_rsa"
64+
65+
if [[ -n "$JUMPHOST_SERVER" ]]; then
66+
ssh-keyscan -H "$JUMPHOST_SERVER" >> /etc/ssh/known_hosts
67+
fi
5368
else
5469
# Generate a key-pair
5570
ssh-keygen -t rsa -b 4096 -C "GH-actions-ssh-deploy-key" -f "$HOME/.ssh/id_rsa" -N ""
@@ -63,6 +78,9 @@ fi
6378

6479
if [[ -n "$VAULT_ADDR" ]]; then
6580
vault write -field=signed_key ssh-client-signer/sign/my-role public_key=@$HOME/.ssh/id_rsa.pub > $HOME/.ssh/signed-cert.pub
81+
fi
82+
83+
if [[ -z "$JUMPHOST_SERVER" ]]; then
6684

6785
# Create ssh config file. `~/.ssh/config` does not work.
6886
cat > /etc/ssh/ssh_config <<EOL
@@ -72,6 +90,19 @@ IdentityFile ${SSH_DIR}/signed-cert.pub
7290
IdentityFile ${SSH_DIR}/id_rsa
7391
User root
7492
EOL
93+
else
94+
# Create ssh config file. `~/.ssh/config` does not work.
95+
cat > /etc/ssh/ssh_config <<EOL
96+
Host jumphost
97+
HostName $JUMPHOST_SERVER
98+
UserKnownHostsFile /etc/ssh/known_hosts
99+
100+
Host $hostname
101+
HostName $hostname
102+
ProxyJump jumphost
103+
UserKnownHostsFile /etc/ssh/known_hosts
104+
User root
105+
EOL
75106
fi
76107

77108
# Check and update submodules if any

0 commit comments

Comments
 (0)