posts: chai #88
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
on: [push] | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
name: Deploy blog to deuterium | |
if: github.ref == 'refs/heads/main' | |
env: | |
MACHINE: deuterium | |
steps: | |
- name: Setup Go 1.19 | |
id: go | |
uses: actions/setup-go@v2 | |
- name: Setup Tailscale | |
id: tailscale | |
uses: tailscale/github-action@v2 | |
with: | |
oauth-client-id: ${{ secrets.TS_OAUTH_CLIENT_ID }} | |
oauth-secret: ${{ secrets.TS_OAUTH_CLIENT_SECRET }} | |
tags: tag:public | |
- name: Add SSH key | |
id: ssh | |
env: | |
SSH_KEY: ${{ secrets.SSH_KEY }} | |
run: | | |
set -euxo pipefail | |
tailscale ping -c 2 $MACHINE | |
mkdir -p ~/.ssh | |
ssh-keyscan $MACHINE > ~/.ssh/known_hosts | |
printf "%s" "$SSH_KEY" > ~/.ssh/key | |
chmod 600 ~/.ssh/key | |
- name: Fetch code | |
id: fetch | |
uses: actions/checkout@v1 | |
- name: Compile blog binary | |
id: compile | |
run: go build -o prose ./cmd/prose | |
- name: Build tarball and ship it | |
id: tarball | |
run: | | |
TIME=$(date +%Y%m%d-%H%M%S) | |
FILENAME=prose-${TIME}.tar.gz | |
mkdir -p static/css | |
tar -czf $FILENAME prose static/ styles/ templates/ posts/ | |
echo $FILENAME "www@$MACHINE:/home/www/" | |
scp -i ~/.ssh/key $FILENAME "www@$MACHINE:/home/www/" | |
ssh -i ~/.ssh/key "www@$MACHINE" "tar -C /var/www/prose.nsood.in -xzf ~/$FILENAME" | |
ssh -i ~/.ssh/key "www@$MACHINE" "sudo systemctl restart prose" |