fgo-ta-com-website/.forgejo/workflows/ssh-setup.yml

28 lines
1,003 B
YAML
Raw Normal View History

2023-12-19 20:03:28 +00:00
name: "ssh & rsync setup"
inputs:
SSH_KNOWN_HOSTS:
required: true
description: "Known hosts file to use"
DEPLOY_HOST:
required: true
description: "hostname"
SSH_PRIVATE_KEY:
required: true
description: "SSH private key"
runs:
using: "composite"
steps:
- run: 'which rsync || ( apt update -y && apt install rsync -y )'
- run: 'which ssh-agent || ( apt update -y && apt install openssh-client -y)'
- run: eval $(ssh-agent -s)
- run: mkdir -p ~/.ssh
- run: chmod 700 ~/.ssh
- run: echo "$SSH_PRIVATE_KEY" | tr -d '\r' >> ~/.ssh/key_firq
- run: chmod 600 ~/.ssh/key_firq
- run: echo "Host $DEPLOY_HOST" >> ~/.ssh/config
- run: echo $'\n\tIdentityFile ~/.ssh/key_firq' >> ~/.ssh/config
- run: echo $'\n\tStrictHostKeyChecking no\n\tIdentitiesOnly yes\n' >> ~/.ssh/config
- run: chmod 644 ~/.ssh/config
- run: echo "$SSH_KNOWN_HOSTS" > ~/.ssh/known_hosts
- run: chmod 644 ~/.ssh/known_hosts