-
Notifications
You must be signed in to change notification settings - Fork 0
71 lines (64 loc) · 1.93 KB
/
ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
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 }}"