Add basic GitHub Action
This commit is contained in:
10
Dockerfile
Normal file
10
Dockerfile
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
FROM alpine:3.19
|
||||||
|
|
||||||
|
RUN apk add --no-cache --upgrade \
|
||||||
|
openssh \
|
||||||
|
rsync
|
||||||
|
|
||||||
|
ADD deploy.sh /
|
||||||
|
RUN chmod +x /deploy.sh
|
||||||
|
|
||||||
|
ENTRYPOINT ["/deploy.sh"]
|
||||||
29
README.md
Normal file
29
README.md
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
# rsync deploy action
|
||||||
|
|
||||||
|
Example usage:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
name: 'Build and deploy'
|
||||||
|
run-name: 'Build and Deploy'
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
deploy-blog:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout
|
||||||
|
- name: Deploy files
|
||||||
|
uses: https://git.roy.lv/actions/rsync-deploy-action # Full URL is Gitea Actions specific
|
||||||
|
env:
|
||||||
|
SSH_KEY: ${{ secrets.SSH_KEY }}
|
||||||
|
RSYNC_SOURCE: ./*
|
||||||
|
RSYNC_DESTINATION: /path/to/rsync/to/
|
||||||
|
RSYNC_USERHOST: user@example.host
|
||||||
|
with:
|
||||||
|
rsync-arguments: --archive --compress --delete --verbose
|
||||||
|
```
|
||||||
17
action.yml
Normal file
17
action.yml
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
name: Deploy to server with rsync
|
||||||
|
description: An action to build and deploy to a server with rsync over SSH
|
||||||
|
branding:
|
||||||
|
icon: upload-cloud
|
||||||
|
color: blue
|
||||||
|
|
||||||
|
inputs:
|
||||||
|
rsync-arguments:
|
||||||
|
description: Rsync arguments
|
||||||
|
required: false
|
||||||
|
default: --archive --compress --delete --verbose
|
||||||
|
|
||||||
|
runs:
|
||||||
|
using: docker
|
||||||
|
image: Dockerfile
|
||||||
|
args:
|
||||||
|
- ${{ inputs.rsync-arguments }}
|
||||||
16
deploy.sh
Executable file
16
deploy.sh
Executable file
@@ -0,0 +1,16 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
options="$1"
|
||||||
|
SSH_HOME="${HOME}/.ssh"
|
||||||
|
SSH_KEYPATH="${SSH_HOME}/deploy_key"
|
||||||
|
|
||||||
|
mkdir -p "$SSH_HOME"
|
||||||
|
echo "$SSH_KEY" > "$SSH_KEYPATH"
|
||||||
|
chmod 600 "$SSH_KEYPATH"
|
||||||
|
|
||||||
|
echo "Deploying..."
|
||||||
|
rsync $options \
|
||||||
|
-e "ssh -i $SSH_KEYPATH -o StrictHostKeyChecking=no" \
|
||||||
|
"$RSYNC_SOURCE" "$RSYNC_USERHOST":"$RSYNC_DESTINATION"
|
||||||
Reference in New Issue
Block a user