generated from Fedodo/Fedodo.README.Template
-
Notifications
You must be signed in to change notification settings - Fork 0
108 lines (84 loc) · 2.77 KB
/
HugoBuildAndDeploy.yaml
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
name: HugoBuildAndDeploy
on:
workflow_dispatch:
push:
branches: [main]
env:
NAME: ./
CONTAINER-NAME: fedodo-docs
jobs:
ReleaseVersion:
runs-on: ubuntu-latest
steps:
# Checkout the repository
- uses: actions/checkout@v3
# Install Hugo
- name: Hugo setup
uses: peaceiris/[email protected]
with:
extended: true
# Install dependencies
- run: npm install -D autoprefixer
working-directory: ./${{ env.NAME }}/
- run: npm install -D postcss-cli
working-directory: ./${{ env.NAME }}/
# Build the hugo repository
- run: hugo
working-directory: ./${{ env.NAME }}/
- name: Login to Docker Hub
uses: docker/login-action@v1
with:
username: fedodo
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build the Docker image
run: docker build . --file ./${{ env.NAME }}/Dockerfile --tag fedodo/${{ env.CONTAINER-NAME }}:${{ github.run_number }}
- name: Push the image to dockerhub
run: docker push fedodo/${{ env.CONTAINER-NAME }}:${{ github.run_number }}
ReleaseLatest:
runs-on: ubuntu-latest
steps:
# Checkout the repository
- uses: actions/checkout@v3
# Install Hugo
- name: Hugo setup
uses: peaceiris/[email protected]
with:
extended: true
# Install dependencies
- run: npm install -D autoprefixer
working-directory: ./${{ env.NAME }}/
- run: npm install -D postcss-cli
working-directory: ./${{ env.NAME }}/
# Build the hugo repository
- run: hugo
working-directory: ./${{ env.NAME }}/
- name: Login to Docker Hub
uses: docker/login-action@v1
with:
username: fedodo
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build the Docker image
run: docker build . --file ./${{ env.NAME }}/Dockerfile --tag fedodo/${{ env.CONTAINER-NAME }}:latest
- name: Push the image to dockerhub
run: docker push fedodo/${{ env.CONTAINER-NAME }}:latest
DeployContainer:
needs: ReleaseVersion
runs-on: ubuntu-latest
steps:
# Download Secure-File
- name: base64-to-file
id: write_file
uses: timheuer/[email protected]
with:
fileName: "custom-config"
encodedString: ${{ secrets.KUBECTL_CONFIG }}
# Checkout the repository
- uses: actions/checkout@v3
- name: Find and Replace
uses: jacobtomlinson/gha-find-replace@v3
with:
find: "{{RUN_NUMBER}}"
replace: ${{ github.run_number }}
regex: false
# Deploy Kubernetes YAML
- run: kubectl apply -f ./Deployment/Kubernetes.yaml --kubeconfig ${{ steps.write_file.outputs.filePath }}