ci: remove binary cache and add fonts cache #67
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" | |
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: "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: "Test" | |
run: "make test" | |
- 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: "Build binary" | |
if: "steps.bin-cache.outputs.cache-hit != 'true'" | |
run: "make build" | |
- name: "Render" | |
run: "make run" | |
- 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' |