chore: move all rendering code to renderer dir #72
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
name: "CD pipeline — build, test, deploy" | |
defaults: | |
run: | |
working-directory: "renderer" | |
on: | |
push: | |
branches: [ master ] | |
workflow_dispatch: | |
jobs: | |
build: | |
runs-on: "ubuntu-latest" | |
steps: | |
- uses: "actions/checkout@v4" | |
- name: "Setup Go environment" | |
uses: "actions/setup-go@v4" | |
with: | |
go-version: "1.21" | |
- name: "Go version" | |
run: "go version" | |
- name: "Build binary" | |
run: "make build" | |
- name: "Test" | |
run: "make test" | |
- name: "Cache tailwind binary" | |
id: "tailwind-cache" | |
uses: "actions/cache@v3" | |
with: | |
path: "bin/tailwindcss" | |
key: "${{ runner.os }}-tailwind-${{ hashFiles('preprocess/tailwind/version.go') }}" | |
restore-keys: | | |
${{ runner.os }}-tailwind- | |
- name: "Cache fonts" | |
id: "fonts-cache" | |
uses: "actions/cache@v3" | |
with: | |
path: "_site/font" | |
key: "${{ runner.os }}-fonts-${{ hashFiles('_site/font/font.list') }}" | |
restore-keys: | | |
${{ runner.os }}-fonts- | |
- name: "Render" | |
run: "./renderblog -f=1 -v=3" | |
- name: "Archive" | |
run: "make archive" | |
- name: "Upload dist artifact" | |
uses: "actions/upload-artifact@v3" | |
with: | |
name: "blog-sewera-dev-dist-archive" | |
path: | | |
dist.tar | |
deploy: | |
needs: "build" | |
environment: "production" | |
concurrency: "production" | |
runs-on: "ubuntu-latest" | |
steps: | |
- name: "Add SSH key" | |
env: | |
SSH_AUTH_SOCK: "/tmp/ssh_agent.sock" | |
run: | | |
mkdir -p /home/runner/.ssh | |
ssh-keyscan sewera.dev >> /home/runner/.ssh/known_hosts | |
echo "${{ secrets.BLOG_PROD_KEY }}" > /home/runner/.ssh/github_actions | |
chmod 600 /home/runner/.ssh/github_actions | |
ssh-agent -a $SSH_AUTH_SOCK > /dev/null | |
ssh-add /home/runner/.ssh/github_actions | |
- name: "Get built artifact" | |
uses: "actions/download-artifact@v3" | |
with: | |
name: "blog-sewera-dev-dist-archive" | |
- name: "Prepare and upload artifact" | |
env: | |
SSH_AUTH_SOCK: "/tmp/ssh_agent.sock" | |
run: | | |
tar -xf dist.tar && \ | |
rm dist.tar && \ | |
tar -czf blog-sewera-dev-dist-archive.zip dist && \ | |
scp -i /home/runner/.ssh/github_actions \ | |
blog-sewera-dev-dist-archive.zip \ | |
${{ secrets.BLOG_PROD_USER }}@sewera.dev:~/blog/ | |
- name: "Deploy to production" | |
env: | |
SSH_AUTH_SOCK: "/tmp/ssh_agent.sock" | |
run: | | |
ssh -i /home/runner/.ssh/github_actions \ | |
${{ secrets.BLOG_PROD_USER }}@sewera.dev \ | |
'./DEPLOY_BLOG' |