forked from helma-org/helma
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add reusable workflow for setting up SSH agent
- Loading branch information
Showing
3 changed files
with
108 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
name: SSH setup | ||
description: Set up the SSH agent | ||
|
||
inputs: | ||
config: | ||
description: The SSH configuration | ||
required: true | ||
key: | ||
description: The private SSH key | ||
required: true | ||
known-hosts: | ||
description: The list of known hosts | ||
required: true | ||
|
||
runs: | ||
using: composite | ||
|
||
steps: | ||
- name: Configure SSH | ||
shell: sh | ||
env: | ||
CONFIG: ${{ inputs.config }} | ||
KNOWN_HOSTS: ${{ inputs.known-hosts }} | ||
run: | | ||
mkdir -p ~/.ssh | ||
echo "${CONFIG}" > ~/.ssh/config | ||
echo "${KNOWN_HOSTS}" > ~/.ssh/known_hosts | ||
- name: Start SSH agent | ||
shell: bash | ||
env: | ||
SOCKET: /tmp/ssh-agent.sock | ||
run: | | ||
echo "SSH_AUTH_SOCK=${SOCKET}" >> $GITHUB_ENV | ||
ssh-agent -a ${SOCKET} > /dev/null | ||
- name: Add SSH key | ||
shell: bash | ||
env: | ||
KEY: ${{ inputs.key }} | ||
run: | | ||
ssh-add - <<< "${KEY}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
#!/bin/sh | ||
|
||
# Use this script as forced command of an authorized SSH key: | ||
# command="/home/helma/extras/deploy.sh" ssh-ed25519 AAAAC3NzaC… | ||
|
||
case "$SSH_ORIGINAL_COMMAND" in | ||
ping) | ||
echo pong | ||
;; | ||
|
||
deploy-helma) | ||
rsync ./ p3k.org:./ \ | ||
--archive --compress --delete --verbose \ | ||
--filter '+ /bin' \ | ||
--filter '+ /extras' \ | ||
--filter '+ /launcher.jar' \ | ||
--filter '- /lib/ext' \ | ||
--filter '+ /lib' \ | ||
--filter '+ /modules' \ | ||
--filter '- /*' | ||
;; | ||
|
||
deploy-antville) | ||
rsync ./apps/antville/ p3k.org:./apps/antville/ \ | ||
--archive --compress --delete --verbose \ | ||
--filter '+ /claustra' \ | ||
--filter '+ /code' \ | ||
--filter '+ /compat' \ | ||
--filter '+ /i18n' \ | ||
--filter '+ /lib' \ | ||
--filter '- /*' | ||
rsync ./apps/antville/static/helma/ p3k.org:/var/www/weblogs.at/ \ | ||
--archive --compress --verbose \ | ||
--filter '+ /fonts' \ | ||
--filter '+ /formica.html' \ | ||
--filter '+ /img' \ | ||
--filter '+ /scripts' \ | ||
--filter '+ /styles' \ | ||
--filter '- /*' | ||
;; | ||
|
||
restart) | ||
printf 'Restarting Helma… ' | ||
sudo /bin/systemctl restart helma | ||
printf '%s\n' 'done.' | ||
;; | ||
|
||
*) | ||
# Allow any rsync command but restrict it to the installation directory | ||
rrsync -wo /home/helma | ||
;; | ||
esac |