2024-06-15 17:02:26 +07:00
|
|
|
name: Production
|
2023-11-11 02:14:28 +07:00
|
|
|
|
|
|
|
on:
|
|
|
|
push:
|
|
|
|
branches:
|
|
|
|
- main
|
|
|
|
|
|
|
|
# allow triggering workflow manually.
|
|
|
|
workflow_dispatch:
|
|
|
|
|
|
|
|
jobs:
|
2024-06-15 17:02:26 +07:00
|
|
|
deploy:
|
|
|
|
name: Build and copy to production server
|
2023-11-11 02:14:28 +07:00
|
|
|
runs-on: ubuntu-latest
|
2023-11-11 15:17:00 +07:00
|
|
|
if: github.repository_owner == 'ditatompel'
|
2023-11-11 03:16:30 +07:00
|
|
|
environment: production
|
2023-11-11 02:14:28 +07:00
|
|
|
permissions:
|
|
|
|
contents: read
|
|
|
|
deployments: write
|
|
|
|
|
|
|
|
steps:
|
|
|
|
- name: Checkout
|
2024-02-24 02:45:30 +07:00
|
|
|
uses: actions/checkout@v4
|
2023-11-11 02:14:28 +07:00
|
|
|
|
|
|
|
- name: Setup Node
|
2024-02-24 02:45:30 +07:00
|
|
|
uses: actions/setup-node@v4
|
2023-11-11 02:14:28 +07:00
|
|
|
with:
|
2024-01-31 20:23:24 +07:00
|
|
|
node-version: "20"
|
2023-11-11 02:14:28 +07:00
|
|
|
|
|
|
|
- name: Cache dependencies
|
2024-02-24 03:47:13 +07:00
|
|
|
uses: actions/cache@v4
|
2023-11-11 02:14:28 +07:00
|
|
|
with:
|
|
|
|
path: ~/.npm
|
|
|
|
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
|
|
|
|
restore-keys: |
|
|
|
|
${{ runner.os }}-node-
|
|
|
|
|
|
|
|
- name: Install dependencies
|
|
|
|
run: npm ci
|
|
|
|
|
|
|
|
- name: Setup Hugo
|
2024-04-03 00:36:07 +07:00
|
|
|
uses: peaceiris/actions-hugo@v3
|
2023-11-11 02:14:28 +07:00
|
|
|
with:
|
2024-08-22 06:09:50 +07:00
|
|
|
hugo-version: "0.133.0"
|
2023-11-11 02:14:28 +07:00
|
|
|
extended: true
|
|
|
|
|
|
|
|
- name: Cache Hugo modules
|
2024-02-24 03:47:13 +07:00
|
|
|
uses: actions/cache@v4
|
2023-11-11 02:14:28 +07:00
|
|
|
with:
|
|
|
|
path: /tmp/hugo_cache
|
|
|
|
key: ${{ runner.os }}-hugomod-${{ hashFiles('**/go.sum') }}
|
|
|
|
restore-keys: |
|
|
|
|
${{ runner.os }}-hugomod-
|
|
|
|
|
|
|
|
- name: Build
|
|
|
|
run: hugo --minify --gc --enableGitInfo --cleanDestinationDir
|
|
|
|
|
2024-06-15 17:02:26 +07:00
|
|
|
- name: Deploy
|
2023-11-11 02:14:28 +07:00
|
|
|
uses: burnett01/rsync-deployments@5.2
|
|
|
|
with:
|
|
|
|
switches: -avzr --quiet --delete
|
|
|
|
path: public/
|
|
|
|
remote_path: ${{ secrets.DEPLOY_PATH }}
|
|
|
|
remote_host: ${{ secrets.DEPLOY_HOST }}
|
|
|
|
remote_user: ${{ secrets.DEPLOY_USER }}
|
|
|
|
remote_key: ${{ secrets.DEPLOY_KEY }}
|