Clean base - v0.0.1 setup

This commit is contained in:
Keyvan Ebrahimpour 2025-04-11 18:19:22 +00:00
parent c0865327a6
commit cab41db529
7 changed files with 117 additions and 28 deletions

0
.github/workflows/.trigger-test vendored Normal file
View file

View file

@ -1,54 +1,48 @@
name: Build and Deploy to Kubernetes
name: Build and Deploy
on:
push:
branches: [ main ]
branches:
- main
- dev
- 'feat/**'
- 'test/**'
- 'fix/**'
- 'hotfix/**'
env:
VERSION: ${{ vars.VERSION || 'latest' }}
NAMESPACE: ${{ github.ref == 'refs/heads/main' && 'prod' || 'web' }}
jobs:
build-and-deploy:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
env:
KUBECONFIG: ${HOME}/.kube/config
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Debug repository name
run: |
echo "Repository: ${{ github.repository }}"
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and Push Docker Image
- name: Build and push Docker image
run: |
IMAGE_NAME="ghcr.io/${{ github.repository }}"
docker build -t "$IMAGE_NAME:latest" .
docker push "$IMAGE_NAME:latest"
shell: bash
IMAGE_NAME="ghcr.io/${{ github.repository }}:$VERSION"
docker build -t $IMAGE_NAME .
docker push $IMAGE_NAME
- name: Set up Kubeconfig
- name: Set up kubeconfig from secret
run: |
mkdir -p ${HOME}/.kube
echo "${{ secrets.KUBECONFIG_BASE64 }}" | base64 -d > ${HOME}/.kube/config
chmod 600 ${HOME}/.kube/config
export KUBECONFIG=${HOME}/.kube/config
kubectl version --client
kubectl cluster-info
cat ${HOME}/.kube/config
mkdir -p $HOME/.kube
echo "${{ secrets.KUBECONFIG_BASE64 }}" | base64 -d > $HOME/.kube/config
shell: bash
- name: Deploy to Kubernetes
run: |
export KUBECONFIG=${HOME}/.kube/config
IMAGE_NAME="ghcr.io/${{ github.repository }}"
kubectl set image deployment/homepage home=$IMAGE_NAME:v0.0.1 -n web
IMAGE="ghcr.io/${{ github.repository }}:$VERSION"
kubectl set image deployment/homepage home=$IMAGE -n $NAMESPACE
shell: bash

53
.github/workflows/deploy.yaml vendored Normal file
View file

@ -0,0 +1,53 @@
# .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: Debug Variables
run: echo "Repository: ${{ github.repository }}"
- 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"
shell: bash
- name: Set up Kubeconfig
run: |
mkdir -p ~/.kube
echo "${{ secrets.KUBECONFIG_BASE64 }}" | base64 -d > ~/.kube/config
chmod 600 ~/.kube/config
- name: Deploy to Kubernetes
run: |
kubectl set image deployment/homepage homepage=ghcr.io/${{ github.repository }}:latest -n web
- name: Set up kubeconfig
run: |
mkdir -p ~/.kube
echo "${{ secrets.KUBECONFIG_BASE64 }}" | base64 -d > ~/.kube/config
chmod 600 ~/.kube/config
env:
KUBECONFIG: ~/.kube/config

40
.github/workflows/docker.yml vendored Normal file
View file

@ -0,0 +1,40 @@
name: Build and Push Docker Image
on:
push:
branches: [ main ]
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- 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="ghcr.io/${{ github.repository }}"
docker build -t "$IMAGE:latest" .
docker push "$IMAGE:latest"
- name: Set up Kubeconfig
run: |
mkdir -p ~/.kube
echo "${{ secrets.KUBECONFIG_BASE64 }}" | base64 -d > ~/.kube/config
chmod 600 ~/.kube/config
env:
KUBECONFIG: ~/.kube/config
- name: Deploy to Kubernetes
run: |
IMAGE="ghcr.io/${{ github.repository }}"
kubectl set image deployment/homepage homepage=$IMAGE:latest -n web

1
.trigger-test Normal file
View file

@ -0,0 +1 @@
# trigger test Fri Apr 11 14:35:35 UTC 2025

0
trigger-workflow.txt Normal file
View file

1
version.txt Normal file
View file

@ -0,0 +1 @@
v0.0.4