Deploy website to production server #299
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: Deploy website to production server | |
on: # yamllint disable-line rule:truthy | |
push: | |
branches: | |
- main | |
schedule: | |
- cron: '22 2 * * *' | |
jobs: | |
deploy: | |
runs-on: ubuntu-22.04 | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
submodules: true | |
fetch-depth: 0 | |
- name: Setup Hugo | |
uses: peaceiris/actions-hugo@v2 | |
with: | |
hugo-version: '0.121.2' | |
extended: true | |
- name: Setup Node | |
uses: actions/setup-node@v4 | |
with: | |
node-version: '20' | |
cache: 'npm' | |
cache-dependency-path: '**/package-lock.json' | |
- name: Prepare npm | |
run: npm ci | |
- name: Build | |
env: | |
HUGO_ENV: production | |
HUGO_MATRIX_ACCESS_TOKEN: ${{ secrets.HUGO_MATRIX_ACCESS_TOKEN }} | |
HUGO_MATRIX_HOME_SERVER: ${{ secrets.HUGO_MATRIX_HOME_SERVER }} | |
HUGO_GITHUB_ACCESS_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
URL_PRODUCTION: ${{ vars.URL_PRODUCTION }} | |
run: hugo --minify -b "$URL_PRODUCTION" | |
- name: Deploy | |
uses: appleboy/scp-action@master | |
with: | |
host: ${{ vars.IP_PRODUCTION }} | |
username: ${{ secrets.SSH_USERNAME_PRODUCTION }} | |
key: ${{ secrets.SSH_KEY_PRODUCTION }} | |
source: "public/" | |
target: ${{ vars.WEBROOT_PRODUCTION }} | |
strip_components: 1 |