Merge pull request #65 from Hanaemong/nayoung #3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Backend CI/CD | |
on: | |
push: | |
branches: | |
- develop | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v4 | |
with: | |
java-version: '17' | |
distribution: 'temurin' | |
- name: Grant execute permission for gradlew | |
run: chmod +x ./gradlew | |
- name: Build with Gradle | |
run: ./gradlew build | |
- name: Log in to Docker Hub | |
run: echo ${{ secrets.DOCKER_PASSWORD }} | docker login -u ${{ secrets.DOCKER_USERNAME }} --password-stdin | |
- name: Build Docker image | |
run: docker build -t ${{ secrets.DOCKER_USERNAME }}/hanalink-spring-boot:latest . | |
- name: Push Docker image | |
run: docker push ${{ secrets.DOCKER_USERNAME }}/hanalink-spring-boot:latest | |
- name: Set up kubectl | |
run: | | |
mkdir -p $HOME/.kube | |
echo "${{ secrets.KUBECONFIG_DATA }}" | base64 --decode > $HOME/.kube/config | |
- name: Delete old pods | |
run: kubectl delete pods -l app=hanalink-spring-boot-app | |
- name: Deploy to Kubernetes | |
run: kubectl set image deployment/hanalink-spring-boot-app hanalink-spring-boot-app=${{ secrets.DOCKER_USERNAME }}/hanalink-spring-boot:latest |