Update for 2023 #19
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: Build Site | |
on: | |
push: | |
branches: | |
- master | |
workflow_dispatch: | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Use Node.js 18 | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 18 | |
- name: node_modules CI Cache | |
uses: actions/cache@v3 | |
with: | |
path: ${{ github.workspace }}/node_modules | |
key: ${{ runner.os }}-node_modules-${{ hashFiles('**/package-lock.json') }} | |
- name: Next.js CI Cache | |
uses: actions/cache@v3 | |
with: | |
path: ${{ github.workspace }}/.next/cache | |
# Generate a new cache whenever packages or source files change. | |
key: ${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json') }}-${{ hashFiles('src/**', 'contents/**') }} | |
# If source files changed but packages didn't, rebuild from a prior cache. | |
restore-keys: | | |
${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json') }}- | |
- name: Install Dependencies | |
run: npm clean-install | |
- name: Build Site | |
run: npm run build && npm run export | |
- name: Upload Build Output to Artifacts | |
uses: actions/upload-artifact@v3 | |
with: | |
name: dist | |
path: ${{ github.workspace }}/out/ | |
if-no-files-found: error | |
deploy: | |
runs-on: ubuntu-latest | |
needs: [build] | |
strategy: | |
matrix: | |
include: | |
- host_id: REMOTE_HOST_SYD | |
- host_id: REMOTE_HOST_DUS | |
- host_id: REMOTE_HOST_FRA | |
- host_id: REMOTE_HOST_AMS | |
- host_id: REMOTE_HOST_LON | |
- host_id: REMOTE_HOST_SJC | |
- host_id: REMOTE_HOST_NRT | |
- host_id: REMOTE_HOST_KIX | |
- host_id: REMOTE_HOST_HKG | |
- host_id: REMOTE_HOST_TLL | |
fail-fast: false | |
env: | |
REMOTE_HOST: ${{ secrets[matrix.host_id] }} | |
steps: | |
- uses: actions/download-artifact@v3 | |
with: | |
name: dist | |
path: ${{ github.workspace }}/out/ | |
- run: ls -R ${{ github.workspace }}/out/ | |
- uses: easingthemes/[email protected] | |
env: | |
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }} | |
ARGS: '-avz --delete' | |
REMOTE_HOST: ${{ env.REMOTE_HOST }} | |
REMOTE_USER: ${{ secrets.REMOTE_USER }} | |
SOURCE: out/* | |
TARGET: /home/github/dns.sb/ | |
EXCLUDE: .git,.github,.gitlab-ci.yml,.nojekyll |