Skip to content

Commit

Permalink
create deployment workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
Muirrum committed Oct 25, 2023
1 parent 22866ef commit bd4434d
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,46 @@ jobs:
with:
name: hkgi.tar.gz
path: hkgi.tar.gz

deploy:
runs-on: ubuntu-latest
environment: production
if:
contains('refs/heads/master', github.ref)
steps:
- name: Download latest package
uses: actions/download-artifact@v3
with:
name: hkgi.tar.gz

- name: Deploy with SCP
uses: i3h/deploy-with-scp@v1
with:
src: ./hkgi.tar.gz
dest: ${{ secrets.SSH_DIR }}/hkgi-new.tar.gz
username: ${{ secrets.SSH_USER }}
server-ip: ${{ secrets.SSH_HOST }}
ssh-key: ${{ secrets.SSH_KEY }}

- name: Configure SSH
run: |
mkdir -p ~/.ssh
echo "$SSH_KEY" >> ~/.ssh/id_rsa
chmod 0600 ~/.ssh/id_rsa
cat >>~/.ssh/config <<END
Host production
Hostname $SSH_HOST
User $SSH_USER
IdentityFile ~/.ssh/id_rsa
StrictHostKeyChecking no
END
env:
SSH_USER: ${{ secrets.SSH_USER }}
SSH_HOST: ${{ secrets.SSH_HOST }}
SSH_KEY: ${{ secrest.SSH_KEY }}

- name: Extract tarball on production host
run: ssh staging tar xzvf "$SSH_DIR/hkgi-new.tar.gz" -C "$SSH_DIR"

- name: Restart service on production host
run: ssh staging /usr/bin/sudo /usr/bin/systemctl restart hkgi

0 comments on commit bd4434d

Please sign in to comment.