initial commit
This commit is contained in:
commit
accafc15d5
2 changed files with 80 additions and 0 deletions
31
action.sh
Executable file
31
action.sh
Executable file
|
@ -0,0 +1,31 @@
|
||||||
|
# Set up private key in a five
|
||||||
|
|
||||||
|
SSH_KEY_FILE=/tmp/gitea-pages-ssh-key-$(date +%s)
|
||||||
|
|
||||||
|
# set up ssh private key
|
||||||
|
echo "${INPUT_SSH_KEY}" >> "${SSH_KEY_FILE}"
|
||||||
|
chmod 600 "${SSH_KEY_FILE}"
|
||||||
|
|
||||||
|
# set up ssh remote key
|
||||||
|
echo "${INPUT_HOST} ${INPUT_HOST_KEY}" >> ~/.ssh/known_hosts
|
||||||
|
|
||||||
|
# optionally: create index
|
||||||
|
if [ "${INPUT_INDEX}" ]; then
|
||||||
|
if [ ! -e "${INPUT_DIRECTORY}/index.html" ]; then
|
||||||
|
tree -H "${INPUT_DIRECTORY}" \
|
||||||
|
-D \
|
||||||
|
--charset utf-8 \
|
||||||
|
-T "${INPUT_INDEX_TITLE}" \
|
||||||
|
> "${INPUT_DIRECTORY}/index.html"
|
||||||
|
echo "Added index"
|
||||||
|
else
|
||||||
|
echo "File index.html exists, not overriding."
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
# deploy via ssh
|
||||||
|
tar -C "${INPUT_DIRECTORY}" -czf - . \
|
||||||
|
| ssh -o "IdentitiesOnly=yes" -i "${SSH_KEY_FILE}" \
|
||||||
|
"${INPUT_HOST_USER}@${INPUT_HOST}"
|
||||||
|
|
49
action.yaml
Normal file
49
action.yaml
Normal file
|
@ -0,0 +1,49 @@
|
||||||
|
name: 'Deploy to Pages'
|
||||||
|
description: 'Deploy files to static html server via ssh'
|
||||||
|
author: 'Maximilian Keßler'
|
||||||
|
inputs:
|
||||||
|
host:
|
||||||
|
description: >
|
||||||
|
Server to deploy to.
|
||||||
|
The action will ssh to this endpoint to try to deploy files.
|
||||||
|
default: pabstractnonsen.se
|
||||||
|
host-user:
|
||||||
|
description: >
|
||||||
|
User used for host authentication.
|
||||||
|
default: pages
|
||||||
|
hostkey:
|
||||||
|
description: >
|
||||||
|
SSH host key fingerprint of the specified host, including the key type.
|
||||||
|
If this does not match the host key fingerprint upon invocation of ssh,
|
||||||
|
the action will fail
|
||||||
|
default: ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIAufJTq206GOv0D8gHs2o3eDusLNWaB0U7JRhUYnux9B
|
||||||
|
ssh-key:
|
||||||
|
description: >
|
||||||
|
SSH key used to authenticate to host.
|
||||||
|
default: ${{ secrets.pages_ssh_key }}
|
||||||
|
directory:
|
||||||
|
description: >
|
||||||
|
Directory to deploy.
|
||||||
|
default: pages
|
||||||
|
index:
|
||||||
|
description: >
|
||||||
|
Whether to create an index.html file recursively listing the directory
|
||||||
|
default: true
|
||||||
|
index-title:
|
||||||
|
description: >
|
||||||
|
Title that will be displayed in the index.html
|
||||||
|
default: ${{ github.repository }}
|
||||||
|
runs:
|
||||||
|
using: composite
|
||||||
|
steps:
|
||||||
|
- shell: bash
|
||||||
|
run: |
|
||||||
|
"${GITHUB_ACTION_PATH}/action.sh"
|
||||||
|
env:
|
||||||
|
INPUT_HOST: ${{ inputs.host }}
|
||||||
|
INPUT_HOST_USER: ${{ inputs.host-user }}
|
||||||
|
INPUT_HOST_KEY: ${{ inputs.hostkey }}
|
||||||
|
INPUT_SSH_KEY: ${{ inputs.ssh-key }}
|
||||||
|
INPUT_DIRECTORY: ${{ inputs.directory }}
|
||||||
|
INPUT_INDEX: ${{ inputs.index }}
|
||||||
|
INPUT_INDEX_TITLE: ${{ inputs.index-title }}
|
Loading…
Reference in a new issue