add automated Docker build, push, k3s deploy via Actions
This commit is contained in:
+44
-11
@@ -1,22 +1,55 @@
|
||||
name: Deploy to Host Test
|
||||
name: Build and Push Docker Image
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [master]
|
||||
branches:
|
||||
- main
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
host-deploy-test:
|
||||
build-and-push-test:
|
||||
name: 'Docker Build and Push to Gitea Registry'
|
||||
env:
|
||||
REGISTRY_USERNAME: nicholas
|
||||
IMAGE_REGISTRY: git.uuard.com
|
||||
IMAGE_NAME: nicholas/proving-ground
|
||||
IMAGE_TAG: latest
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Check out repository code
|
||||
- name: 📂 Checkout repo
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: List files in workspace
|
||||
run: |
|
||||
echo "📂 Repository ${{ gitea.repository }}"
|
||||
echo "➡️ Branch ${{ gitea.ref }}"
|
||||
ls ${{ gitea.workspace }}
|
||||
- name: 🔐 Gitea Registry Login
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
registry: ${{ env.IMAGE_REGISTRY }}
|
||||
username: ${{ env.REGISTRY_USERNAME }}
|
||||
password: ${{ secrets.REGISTRY_TOKEN }}
|
||||
|
||||
- name: Copy workspace content to host
|
||||
- name: 🐋 Build Docker image
|
||||
run: docker build -t $IMAGE_REGISTRY/$IMAGE_NAME:$IMAGE_TAG ./container
|
||||
|
||||
- name: 🚀 Push Docker image
|
||||
run: docker push $IMAGE_REGISTRY/$IMAGE_NAME:$IMAGE_TAG
|
||||
|
||||
- name: 🛠️ Setup kubectl
|
||||
uses: azure/setup-kubectl@v4
|
||||
with:
|
||||
version: 'latest'
|
||||
#id: install
|
||||
|
||||
- name: 🔑 Configure Kubeconfig
|
||||
run: |
|
||||
sudo cp -r . /data/www/proving-ground/
|
||||
echo "${{ secrets.KUBECONFIG_DATA }}" | base64 -d > kubeconfig.yml
|
||||
|
||||
- name: 🧪 Test access
|
||||
env:
|
||||
KUBECONFIG: kubeconfig.yml
|
||||
run: kubectl get nodes
|
||||
|
||||
#- name: 🚀 Deploy to k3s
|
||||
# run: |
|
||||
# kubectl apply -f k8s/deployment.yaml
|
||||
# kubectl apply -f k8s/service.yaml
|
||||
# kubectl apply -f k8s/ingress.yaml
|
||||
# kubectl rollout status deployment/proving-ground
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
FROM nginx:alpine
|
||||
|
||||
RUN rm -rf /usr/share/nginx/html/*
|
||||
|
||||
COPY site/ /usr/share/nginx/html/
|
||||
|
||||
EXPOSE 80
|
||||
@@ -0,0 +1,28 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<title>Hello, World!</title>
|
||||
<style>
|
||||
body {
|
||||
font-family: Arial, sans-serif;
|
||||
margin: 3rem;
|
||||
background-color: #f9f9f9;
|
||||
color: #333;
|
||||
text-align: center;
|
||||
}
|
||||
h1 {
|
||||
color: #007acc;
|
||||
}
|
||||
p {
|
||||
font-size: 1.2rem;
|
||||
margin-top: 1rem;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Behold</h1>
|
||||
<p>The Cosmos is all that is or was or ever will be. Our feeblest contemplations of the Cosmos stir us — there is a tingling in the spine, a catch in the voice, a faint sensation, as if a distant memory, of falling from a height. We know we are approaching the greatest of mysteries. </p>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,21 @@
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: proving-ground
|
||||
labels:
|
||||
app: proving-ground-static-site
|
||||
spec:
|
||||
replicas: 1
|
||||
selector:
|
||||
matchLabels:
|
||||
app: proving-ground-static-site
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: proving-ground-static-site
|
||||
spec:
|
||||
containers:
|
||||
- name: nginx
|
||||
image: git.uuard.com/nicholas/proving-ground:latest
|
||||
ports:
|
||||
- containerPort: 80
|
||||
@@ -0,0 +1,16 @@
|
||||
apiVersion: networking.k8s.io/v1
|
||||
kind: Ingress
|
||||
metadata:
|
||||
name: proving-ground-static-site-ingress
|
||||
spec:
|
||||
rules:
|
||||
- host: localhost
|
||||
http:
|
||||
paths:
|
||||
- path: /
|
||||
pathType: Prefix
|
||||
backend:
|
||||
service:
|
||||
name: proving-ground-static-site-service
|
||||
port:
|
||||
number: 80
|
||||
@@ -0,0 +1,12 @@
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: proving-ground-static-site-service
|
||||
spec:
|
||||
selector:
|
||||
app: proving-ground-static-site
|
||||
ports:
|
||||
- protocol: TCP
|
||||
port: 80
|
||||
targetPort: 80
|
||||
type: LoadBalancer
|
||||
Reference in New Issue
Block a user