prose/.forgejo/workflows/main.yml
Naman Sood a8a4e3559e
Some checks failed
/ Deploy blog to deuterium (push) Failing after 38s
runner doesn't have pipefail
Signed-off-by: Naman Sood <mail@nsood.in>
2024-11-21 21:19:58 -05:00

67 lines
1.9 KiB
YAML

on:
push:
branches:
- 'main'
jobs:
deploy:
runs-on: docker
container:
image: node:lts-bullseye
options: "--cap-add=NET_ADMIN --device=/dev/net/tun"
name: Deploy blog to deuterium
env:
MACHINE: deuterium
steps:
- name: Setup Go
id: go
with:
go-version: '>=1.23.0'
uses: https://code.forgejo.org/actions/setup-go@v5
- name: Install tailscale deps
id: deps
run: |
apt update && apt install -y sudo iptables iproute2
- name: Setup Tailscale
id: tailscale
uses: https://github.com/tailscale/github-action@v2
with:
oauth-client-id: ${{ secrets.TS_OAUTH_CLIENT_ID }}
oauth-secret: ${{ secrets.TS_OAUTH_CLIENT_SECRET }}
tags: tag:public
- name: See what happened to tailscale
id: failscale
if: failure()
run: |
cat ~/tailscaled.log
- name: Add SSH key
id: ssh
env:
SSH_KEY: ${{ secrets.SSH_KEY }}
run: |
set -eux
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: https://code.forgejo.org/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"