From 0e2c8862e8aee81506bacd0f940ebbfad61971e2 Mon Sep 17 00:00:00 2001 From: alessandrovitali Date: Tue, 19 May 2026 22:57:25 +0200 Subject: [PATCH] feat: add composite actions --- backup/action.yml | 13 +++++++++++++ ssh-copy/action.yml | 38 ++++++++++++++++++++++++++++++++++++++ ssh-run/action.yml | 36 ++++++++++++++++++++++++++++++++++++ 3 files changed, 87 insertions(+) create mode 100644 backup/action.yml create mode 100644 ssh-copy/action.yml create mode 100644 ssh-run/action.yml diff --git a/backup/action.yml b/backup/action.yml new file mode 100644 index 0000000..6fd17f3 --- /dev/null +++ b/backup/action.yml @@ -0,0 +1,13 @@ +name: backup +description: backup all postgres databases + +runs: + using: "composite" + steps: + - name: dump databases + shell: bash + run: | + docker ps + + # - name: backup databases + # run: | diff --git a/ssh-copy/action.yml b/ssh-copy/action.yml new file mode 100644 index 0000000..a06c990 --- /dev/null +++ b/ssh-copy/action.yml @@ -0,0 +1,38 @@ +name: SSH copy +description: copy files to SSH hosts +inputs: + host: + description: SSH host + required: true + user: + description: SSH user + required: true + key: + description: SSH private key + required: true + source: + description: directory to copy + required: true + target: + description: destination path on remote + required: true + +runs: + using: "composite" + steps: + - name: setup ssh + shell: bash + run: | + mkdir -p ~/.ssh + echo "${{ inputs.key }}" > ~/.ssh/id_rsa + chmod 600 ~/.ssh/id_rsa + + - name: add remote host to known_hosts + shell: bash + run: ssh-keyscan -H "${{ inputs.host }}" >> ~/.ssh/known_hosts + + ## replace with rsync for proper synchronization + - name: copy directory + shell: bash + run: | + scp -r ${{ inputs.source }} ${{ inputs.user }}@${{ inputs.host }}:${{ inputs.target }} diff --git a/ssh-run/action.yml b/ssh-run/action.yml new file mode 100644 index 0000000..df18ee9 --- /dev/null +++ b/ssh-run/action.yml @@ -0,0 +1,36 @@ +name: SSH runner +description: run commands on SSH hosts +inputs: + host: + description: SSH host + required: true + user: + description: SSH user + required: true + key: + description: SSH private key + required: true + script: + description: commands to run via SSH + required: true + +runs: + using: "composite" + steps: + - name: setup ssh + shell: bash + run: | + mkdir -p ~/.ssh + echo "${{ inputs.key }}" > ~/.ssh/id_rsa + chmod 600 ~/.ssh/id_rsa + + - name: add remote host to known_hosts + shell: bash + run: ssh-keyscan -H "${{ inputs.host }}" >> ~/.ssh/known_hosts + + - name: run on docker host + shell: bash + run: | + ssh ${{ inputs.user }}@${{ inputs.host }} << 'EOF' + ${{ inputs.script }} + EOF