add git action workflow: build image, push to image registry
@@ -0,0 +1,37 @@
|
|||||||
|
name: Deployment
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
deploy-site:
|
||||||
|
name: 'deploy'
|
||||||
|
env:
|
||||||
|
REGISTRY_USERNAME: nicholas
|
||||||
|
IMAGE_REGISTRY: git.uuard.com
|
||||||
|
IMAGE_NAME: nicholas/personal-website
|
||||||
|
IMAGE_TAG: latest
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: ⬇️ Checkout repo
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: 🔐 Gitea Registry Login
|
||||||
|
uses: docker/login-action@v3
|
||||||
|
with:
|
||||||
|
registry: ${{ env.IMAGE_REGISTRY }}
|
||||||
|
username: ${{ env.REGISTRY_USERNAME }}
|
||||||
|
password: ${{ secrets.REGISTRY_TOKEN }}
|
||||||
|
|
||||||
|
- 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: 🧹 Prune images
|
||||||
|
if: always()
|
||||||
|
run: docker image prune -f
|
||||||
@@ -1,27 +0,0 @@
|
|||||||
pipeline {
|
|
||||||
agent any
|
|
||||||
environment {
|
|
||||||
DEPLOY_DIR = '/mnt/jenkins_deployments/personal-website'
|
|
||||||
}
|
|
||||||
stages {
|
|
||||||
stage('Checkout') {
|
|
||||||
steps {
|
|
||||||
checkout scm
|
|
||||||
}
|
|
||||||
}
|
|
||||||
stage('copy to nginx server') {
|
|
||||||
steps {
|
|
||||||
sh """
|
|
||||||
rm -rf ${DEPLOY_DIR}/*
|
|
||||||
cp -r ${WORKSPACE}/* ${DEPLOY_DIR}/
|
|
||||||
chmod -R 755 ${DEPLOY_DIR}
|
|
||||||
"""
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
post {
|
|
||||||
failure {
|
|
||||||
echo "Build Failed"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
FROM nginx:alpine
|
||||||
|
|
||||||
|
RUN rm -rf /usr/share/nginx/html/*
|
||||||
|
|
||||||
|
COPY site/ /usr/share/nginx/html/
|
||||||
|
|
||||||
|
EXPOSE 80
|
||||||
|
Before Width: | Height: | Size: 1.9 KiB After Width: | Height: | Size: 1.9 KiB |
|
Before Width: | Height: | Size: 2.0 MiB After Width: | Height: | Size: 2.0 MiB |
|
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.3 KiB |
|
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 15 KiB |
|
Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 1.6 KiB |
|
Before Width: | Height: | Size: 2.7 KiB After Width: | Height: | Size: 2.7 KiB |
|
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 11 KiB |