rewriting actions
This commit is contained in:
parent
2418fe8b4a
commit
fc277f2757
2 changed files with 31 additions and 39 deletions
|
@ -1,27 +0,0 @@
|
|||
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
|
|
@ -38,21 +38,40 @@ jobs:
|
|||
env:
|
||||
DEPLOY_USER: ${{ secrets.DEPLOY_USER }}
|
||||
DEPLOY_HOST: ${{ secrets.DEPLOY_HOST }}
|
||||
SSH_KNOWN_HOSTS: ${{ secrets.SSH_KNOWN_HOSTS }}
|
||||
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
|
||||
steps:
|
||||
- uses: https://code.forgejo.org/actions/checkout@v3
|
||||
- name: Install and update ssh + rsync
|
||||
run: |
|
||||
'which rsync || ( apt update -y && apt install rsync -y)'
|
||||
'which ssh-agent || ( apt update -y && apt install openssh-client -y)'
|
||||
- uses: actions/download-artifact@v3
|
||||
with:
|
||||
name: static-site
|
||||
- uses: ./.forgejo/local-action/ssh-setup
|
||||
- name: Install SSH Key
|
||||
uses: https://github.com/shimataro/ssh-key-action@v2
|
||||
with:
|
||||
DEPLOY_HOST: $DEPLOY_HOST
|
||||
SSH_KNOWN_HOSTS: $SSH_KNOWN_HOSTS
|
||||
SSH_PRIVATE_KEY: $SSH_PRIVATE_KEY
|
||||
- name: Stopping screen session, cleaning
|
||||
run: ssh $DEPLOY_USER@$DEPLOY_HOST "screen -X -S fgo-ta_com-public kill; rm -r -f fgo-ta_com/public/*;"
|
||||
- name: Copying to proxmox machine
|
||||
key: ${{ secrets.SSH_PRIVATE_KEY }}
|
||||
known_hosts: unnecessary
|
||||
- name: Adding Known Hosts
|
||||
run: ssh-keyscan -H ${{ secrets.SSH_HOST }} >> ~/.ssh/known_hosts
|
||||
- name: stop + cleanup
|
||||
uses: https://github.com/appleboy/ssh-action@master
|
||||
with:
|
||||
host: DEPLOY_HOST
|
||||
username: DEPLOY_USER
|
||||
key: ${{ secrets.SSH_PRIVATE_KEY }}
|
||||
script: |
|
||||
screen -X -S fgo-ta_com-public kill
|
||||
rm -r -f fgo-ta_com/public/*
|
||||
- name: copy using rsync
|
||||
run: rsync -az --stats static-site/* $DEPLOY_USER@$DEPLOY_HOST:~/fgo-ta_com/public
|
||||
- name: Restarting screen session
|
||||
run: ssh $DEPLOY_USER@$DEPLOY_HOST 'PATH="$HOME/.local/bin:$PATH"; cd fgo-ta_com; find public -maxdepth 1 -printf "%p\n"; screen -S fgo-ta_com-public -dm serve public/ -p 9200'
|
||||
- name: start
|
||||
uses: https://github.com/appleboy/ssh-action@master
|
||||
with:
|
||||
host: DEPLOY_HOST
|
||||
username: DEPLOY_USER
|
||||
key: ${{ secrets.SSH_PRIVATE_KEY }}
|
||||
script: |
|
||||
PATH="$HOME/.local/bin:$PATH"
|
||||
cd fgo-ta_com
|
||||
find public -maxdepth 1 -printf "%p\n"
|
||||
screen -S fgo-ta_com-public -dm serve public/ -p 9200
|
||||
|
|
Loading…
Reference in a new issue