Skip to content

fix: 파드 unavailable 1로 변경 #28

fix: 파드 unavailable 1로 변경

fix: 파드 unavailable 1로 변경 #28

name: Build and Push Docker Image
on:
push:
branches:
- main
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Java
uses: actions/setup-java@v3
with:
java-version: '21'
distribution: 'temurin'
java-package: jdk
check-latest: false
- name: Set up Gradle
uses: gradle/wrapper-validation-action@v2
- name: Build with Gradle
run: |
./gradlew build
ls -al build/libs
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Cache Docker layers
uses: actions/cache@v4
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Log in to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build and push Docker image
run: |
docker build -t ${{ secrets.DOCKER_USERNAME }}/knutoyproject:${GITHUB_SHA} .
docker push ${{ secrets.DOCKER_USERNAME }}/knutoyproject:${GITHUB_SHA}
- name: Set up kubectl
uses: azure/setup-kubectl@v3
with:
version: 'v1.24.0'
- name: Set up kubeconfig
run: |
mkdir -p ~/.kube
echo "$KUBECONFIG" > ~/.kube/config
env:
KUBECONFIG: ${{ secrets.KUBECONFIG }}
- name: Apply Kubernetes Deployment
run: |
envsubst < ./k8s/deployment.yaml.template > deployment.yaml
kubectl apply -f deployment.yaml --kubeconfig ~/.kube/config --insecure-skip-tls-verify
kubectl set image deployment/knutoyproject knutoyproject=${{ secrets.DOCKER_USERNAME }}/knutoyproject:${GITHUB_SHA} --kubeconfig ~/.kube/config --insecure-skip-tls-verify