Skip to content

...i can spell

...i can spell #8

Workflow file for this run

# This workflow will build a golang project
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go
name: Go
on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.20'
- name: Build
run: go build -v ./...
- name: Package
run: go build && tar czvf hkgi.tar.gz hkgi data migrations
- name: Upload Artifact
uses: actions/upload-artifact@v3
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: ${{ secrets.SSH_KEY }}
- name: Extract tarball on production host
run: ssh staging tar xzvf "$SSH_DIR/hkgi-new.tar.gz" -C "$SSH_DIR"
env:
SSH_DIR: ${{ secrets.SSH_DIR }}
- name: Restart service on production host
run: ssh staging /usr/bin/sudo /usr/bin/systemctl restart hkgi