Skip to content

Commit

Permalink
chore: staging ci/cd 파일 추가(#99)
Browse files Browse the repository at this point in the history
  • Loading branch information
eun-seong committed Feb 29, 2024
1 parent eebfe8a commit 42b32a2
Show file tree
Hide file tree
Showing 6 changed files with 143 additions and 0 deletions.
83 changes: 83 additions & 0 deletions .github/workflows/cicd_staging.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
# 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: stg-namui-wiki

on:
push:
branches:
- staging

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

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/staging/deployment.yaml
6 changes: 6 additions & 0 deletions k8s/staging/configmap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: namui-wiki-stg-configmap
data:
application.yaml: |
54 changes: 54 additions & 0 deletions k8s/staging/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: stg-namui-wiki
name: stg-namui-wiki
namespace: default
spec:
progressDeadlineSeconds: 600
replicas: 1
revisionHistoryLimit: 10
selector:
matchLabels:
app: stg-namui-wiki
strategy:
type: Recreate
template:
metadata:
labels:
app: stg-namui-wiki
name: stg-namui-wiki
spec:
containers:
- image: ghcr.io/rlacksgus97/stg-namui-wiki:latest
imagePullPolicy: Always
name: stg-namui-wiki
resources:
limits:
cpu: '1'
memory: 512Mi
requests:
cpu: 500m
memory: 256Mi
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
volumeMounts:
- mountPath: /config
name: application-properties
readOnly: true
dnsPolicy: ClusterFirst
imagePullSecrets:
- name: registry-secret
restartPolicy: Always
schedulerName: default-scheduler
securityContext: {}
terminationGracePeriodSeconds: 30
volumes:
- configMap:
defaultMode: 420
items:
- key: application.yaml
path: application.yaml
name: namui-wiki-stg-configmap
name: application-properties
Binary file removed src/.DS_Store
Binary file not shown.
Binary file removed src/main/.DS_Store
Binary file not shown.
Binary file removed src/main/resources/config/.DS_Store
Binary file not shown.

0 comments on commit 42b32a2

Please sign in to comment.