Skip to content

Commit

Permalink
chore: 운영 CD 설정(#99)
Browse files Browse the repository at this point in the history
  • Loading branch information
eun-seong committed Feb 29, 2024
1 parent e79cb81 commit c29d5d4
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 61 deletions.
60 changes: 0 additions & 60 deletions .github/workflows/ci.yml

This file was deleted.

84 changes: 84 additions & 0 deletions .github/workflows/cicd_prod.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
# This workflow will build a package using Gradle and then publish it to GitHub packages when a release is created
# For more information see: https://github.com/actions/setup-java/blob/main/docs/advanced-usage.md#Publishing-using-gradle

name: CI/CD

env:
REGISTRY: "ghcr.io"
NAMESPACE: "rlacksgus97"
IMAGE_NAME: "namui-wiki"

on:
push:
branches:
- main

jobs:
build:
name: Build

runs-on: ubuntu-latest
permissions:
contents: read
packages: write

steps:
- uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'corretto'

- name: Build with Gradle
uses: gradle/gradle-build-action@bd5760595778326ba7f1441bcf7e88b49de61a25 # v2.6.0
with:
arguments: build -x test

- name: Log in to the Container registry
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.PACKAGE_REGISTRY_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
with:
images: ${{ env.REGISTRY }}/${{ env.NAMESPACE }}/${{ env.IMAGE_NAME }}

- name: Build and push Docker image
uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4
with:
context: .
push: true
tags: |
${{ env.REGISTRY }}/${{ env.NAMESPACE }}/${{ env.IMAGE_NAME }}:latest
${{ env.REGISTRY }}/${{ env.NAMESPACE }}/${{ env.IMAGE_NAME }}:${{ github.run_id }}
labels: ${{ steps.meta.outputs.labels }}

deploy:
name: Deploy

if: github.ref == 'refs/heads/master'
needs: [ build ]
runs-on: ubuntu-latest

steps:
- name: Checkout source code
uses: actions/checkout@v3

- name: Set up Kubectl
uses: azure/k8s-set-context@v1
with:
kubeconfig: ${{ secrets.KUBECONFIG }}

- name: Deploy
run: |
kubectl apply -f k8s/deployment.yaml
2 changes: 1 addition & 1 deletion k8s/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ spec:
spec:
containers:
- name: "namui-wiki"
image: "ghcr.io/rlacksgus97/namui-wiki:7900533613"
image: "ghcr.io/rlacksgus97/namui-wiki:latest"
resources:
requests:
cpu: 1000m
Expand Down

0 comments on commit c29d5d4

Please sign in to comment.