Add GitHub Actions deploy workflow
This commit is contained in:
parent
408942999f
commit
36227a94b9
1 changed files with 41 additions and 0 deletions
41
.github/workflows/deploy.yaml
vendored
Normal file
41
.github/workflows/deploy.yaml
vendored
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
# .github/workflows/deploy.yaml
|
||||
|
||||
name: Build and Deploy to Kubernetes
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ main ]
|
||||
|
||||
jobs:
|
||||
build-and-deploy:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: read
|
||||
packages: write
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Log in to GitHub Container Registry
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
registry: ghcr.io
|
||||
username: ${{ github.actor }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Build and Push Docker Image
|
||||
run: |
|
||||
IMAGE_NAME=ghcr.io/${{ github.repository }}
|
||||
docker build -t $IMAGE_NAME:latest .
|
||||
docker push $IMAGE_NAME:latest
|
||||
|
||||
- name: Set up Kubeconfig
|
||||
run: |
|
||||
mkdir -p ~/.kube
|
||||
echo "${{ secrets.KUBECONFIG }}" > ~/.kube/config
|
||||
chmod 600 ~/.kube/config
|
||||
|
||||
- name: Deploy to Kubernetes
|
||||
run: |
|
||||
kubectl set image deployment/homepage homepage=ghcr.io/${{ github.repository }}:latest -n web
|
||||
Loading…
Reference in a new issue