add k8s deployment
This commit is contained in:
@@ -1,12 +1,19 @@
|
|||||||
name: Gitea Actions Demo
|
name: Build and Deploy
|
||||||
run-name: ${{ github.actor }} is building and pushing 🚀
|
run-name: ${{ github.actor }} is building and pushing 🚀
|
||||||
on: [push]
|
on:
|
||||||
|
pull_request:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
|
||||||
env:
|
env:
|
||||||
REGISTRY: git.chopark.home
|
REGISTRY: git.chopark.home
|
||||||
|
IMAGE: ${{ gitea.repository }}
|
||||||
|
DEPLOYMENT_NAME: ${{ gitea.repository##*/ }}-deployment # optional generic name
|
||||||
|
CONTAINER_NAME: ${DEPLOYMENT_NAME} # optional generic container name
|
||||||
|
NAMESPACE: catalog # optional namespace for the deployment
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
Explore-Gitea-Actions:
|
build-and-push:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Check out repository code
|
- name: Check out repository code
|
||||||
@@ -23,10 +30,25 @@ jobs:
|
|||||||
|
|
||||||
- name: Build and Push Docker Image
|
- name: Build and Push Docker Image
|
||||||
run: |
|
run: |
|
||||||
docker build -t ${{ env.REGISTRY }}/${{ gitea.repository }}:latest .
|
docker build -t ${{ env.REGISTRY }}/${{ env.IMAGE }}:latest .
|
||||||
docker push ${{ env.REGISTRY }}/${{ gitea.repository }}:latest
|
docker push ${{ env.REGISTRY }}/${{ env.IMAGE }}:latest
|
||||||
|
|
||||||
- name: List files in the repository
|
- name: List files in the repository
|
||||||
run: ls ${{ github.workspace }}
|
run: ls ${{ github.workspace }}
|
||||||
|
|
||||||
- run: echo "🍏 Build and Push status is ${{ job.status }}."
|
- run: echo "🍏 Build and Push status is ${{ job.status }}."
|
||||||
|
|
||||||
|
deploy-to-k8s:
|
||||||
|
needs: build-and-push
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Set Kubeconfig
|
||||||
|
run: |
|
||||||
|
echo "${{ secrets.KUBE_CONFIG }}" > kubeconfig.yaml
|
||||||
|
- name: Update Deployment Image
|
||||||
|
run: |
|
||||||
|
# export KUBECONFIG=kubeconfig.yaml
|
||||||
|
kubectl set image \
|
||||||
|
deployment/${{ env.DEPLOYMENT_NAME }} \
|
||||||
|
${{ env.CONTAINER_NAME }}=${{ env.REGISTRY }}/${{ env.IMAGE }}:latest \
|
||||||
|
-n ${{ env.NAMESPACE }}
|
||||||
Reference in New Issue
Block a user