feat: add book list #59
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@v3 | |
- name: Setup Node.js environment | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 'lts/hydrogen' | |
# https://github.com/actions/cache/blob/main/examples.md | |
- name: Get yarn cache directory path for ui | |
id: yarn-cache-dir-path | |
run: echo "dir=$(yarn config get cacheFolder)" >> $GITHUB_OUTPUT | |
- name: Cache yarn dependencies | |
id: yarn-cache | |
uses: actions/cache@v3 | |
with: | |
path: ${{ steps.yarn-cache-dir-path.outputs.dir }} | |
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} | |
restore-keys: | | |
${{ runner.os }}-yarn- | |
- name: Install yarn dependencies | |
run: yarn | |
- name: Cache fonts | |
id: fonts-cache | |
uses: actions/cache@v3 | |
with: | |
path: 'public/font' | |
key: ${{ runner.os }}-fonts-${{ hashFiles('public/font/font.list') }} | |
restore-keys: | | |
${{ runner.os }}-fonts- | |
- name: Download fonts | |
if: steps.fonts-cache.outputs.cache-hit != 'true' | |
run: yarn fonts | |
- name: Test | |
run: yarn test | |
- name: Build | |
run: yarn build | |
- name: Compress | |
run: yarn tar | |
- name: Archive compressed 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' |