How to use a Gitea secret in a Gitea action for ssh/sftp
Create a secret with the base64 encoded private key as part of the repository settings.
Access the secret in an action like this:
name: Stage blog changes
run-name: ${{ github.actor }} is deploying site to staging π
on: [push]
jobs:
Explore-Gitea-Actions:
runs-on: my-ssl-focal
steps:
- run: echo "π The job was automatically triggered by a ${{ github.event_name }} event."
- name: Check out repository code
uses: actions/checkout@v3
- run: |
apt-get update
apt-get install -y hugo rsync
hugo --baseURL https://staging.urgarg.dev/
- name: Clean the content directory and deploy fresh build π
env:
SSH_KEY: ${{ secrets.TEST_BASE64 }}
run: |
eval $(ssh-agent)
echo $SSH_KEY | base64 -d | ssh-add -
rsync -avz --delete -e "ssh -o StrictHostKeyChecking=no" public/ someuser@urgarg.org:/content/
ssh-add -D
- run: echo "π This job's status is ${{ job.status }}."