Update hugo #196
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: ci | |
on: push | |
jobs: | |
build-static: | |
name: Build static files | |
runs-on: ubuntu-22.04 | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
submodules: "recursive" | |
- name: Setup Hugo | |
uses: peaceiris/actions-hugo@v2 | |
with: | |
hugo-version: "0.123.8" | |
extended: true | |
- name: Build | |
run: hugo --minify --baseURL https://bogdi.xyz/ | |
- name: Upload static | |
uses: actions/upload-artifact@v3 | |
with: | |
name: static | |
path: public | |
build-image: | |
runs-on: ubuntu-22.04 | |
needs: build-static | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Login to DockerHub | |
uses: docker/login-action@v2 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Download static | |
uses: actions/download-artifact@v3 | |
with: | |
name: static | |
path: public | |
- name: Build and push | |
id: docker_build | |
uses: docker/build-push-action@v4 | |
with: | |
push: true | |
context: . | |
tags: | | |
ghcr.io/${{ github.repository }}:latest | |
ghcr.io/${{ github.repository }}:${{ github.sha }} | |
- name: Image digest | |
run: echo ${{ steps.docker_build.outputs.digest }} | |
deploy-image-to-cluster: | |
runs-on: ubuntu-22.04 | |
needs: build-image | |
steps: | |
- name: deploy | |
uses: appleboy/[email protected] | |
with: | |
host: ${{ secrets.HOST }} | |
username: ${{ secrets.USERNAME }} | |
key: ${{ secrets.PRIVATE_KEY }} | |
port: ${{ secrets.PORT }} | |
passphrase: ${{ secrets.PASSPHRASE }} | |
script: bash -c "docker pull ghcr.io/${{ github.repository }}:${{ github.sha }} && docker rm -fv hugo && docker run --name hugo -d --net=host ghcr.io/${{ github.repository }}:${{ github.sha }}" |