Hugo CI #99
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: Hugo CI | |
on: | |
push: | |
branches: [ main ] | |
pull_request: | |
branches: [ main ] | |
workflow_dispatch: | |
inputs: | |
version: | |
description: 'Version to release' | |
required: true | |
jobs: | |
staging: | |
name: Deploy to staging | |
runs-on: ubuntu-latest | |
if: github.event_name == 'push' || github.event_name == 'pull_request' | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
submodules: true | |
- name: Setup Hugo | |
uses: peaceiris/actions-hugo@v2 | |
with: | |
hugo-version: '0.111.3' | |
- name: Build | |
run: hugo --baseURL ${{ secrets.HUGO_STAGING_BASEURL }} --destination blog-staging -D | |
- name: copy file via ssh password | |
uses: appleboy/scp-action@master | |
with: | |
host: ${{ secrets.SSH_HOSTNAME }} | |
username: ${{ secrets.SSH_USERNAME }} | |
password: ${{ secrets.SSH_PASSWORD }} | |
port: ${{ secrets.SSH_PORT }} | |
source: "blog-staging" | |
target: ${{ secrets.SSH_WORKDIR }} | |
production: | |
name: Deploy to production | |
runs-on: ubuntu-latest | |
if: github.event_name == 'workflow_dispatch' | |
permissions: | |
contents: write | |
pages: write | |
id-token: write | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
submodules: true | |
- name: Setup Pages | |
id: pages | |
uses: actions/configure-pages@v4 | |
- name: Setup Hugo | |
uses: peaceiris/actions-hugo@v2 | |
with: | |
hugo-version: '0.111.3' | |
- name: Build | |
env: | |
HUGO_ENVIRONMENT: production | |
HUGO_ENV: production | |
run: hugo --minify | |
- name: Upload artifact | |
uses: actions/upload-pages-artifact@v2 | |
with: | |
path: ./public | |
- name: Deploy to GitHub Pages | |
id: deployment | |
uses: actions/deploy-pages@v3 | |
- name: Git Push | |
run: | | |
git config --global user.email "github-actions[bot]@users.noreply.github.com" | |
git config --global user.name "github-actions[bot]" | |
git tag v${{ github.event.inputs.version }} | |
git push --tags | |
- uses: "marvinpinto/action-automatic-releases@latest" | |
name: Create GH Release | |
with: | |
repo_token: "${{ secrets.GITHUB_TOKEN }}" | |
prerelease: false | |
automatic_release_tag: "latest" |