Skip to content

Commit

Permalink
ci: update for deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
adrinerDP committed Mar 22, 2024
1 parent ee69c03 commit 0c676ef
Show file tree
Hide file tree
Showing 5 changed files with 119 additions and 229 deletions.
109 changes: 0 additions & 109 deletions .github/workflows/deploy.yaml

This file was deleted.

119 changes: 119 additions & 0 deletions .github/workflows/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
name: Deployment

run-name: Deploy to ${{ inputs.environment }} by @${{ github.actor }}

permissions:
id-token: write
contents: read

on:
workflow_dispatch:
inputs:
environment:
description: '배포 대상 환경'
required: true
default: 'alpha'
type: choice
options:
- alpha
- prod
ref:
description: '배포 대상 브랜치/태그'
required: true
default: 'HEAD'
type: string

jobs:
deploy:
runs-on: ubuntu-latest

env:
GIT_REF: ${{ inputs.ref == 'HEAD' && 'refs/heads/main' || format('refs/tags/{0}', inputs.ref) }}
GIT_PROJECT_NAME: meeting
HARBOR_REGISTRY: harbor.uoslife.net
HARBOR_PROJECT: uoslife-${{ inputs.environment }}-v1
HARBOR_REPOSITORY: meeting-server
HARBOR_USERNAME: ${{ secrets.HARBOR_USERNAME }}
HARBOR_PASSWORD: ${{ secrets.HARBOR_PASSWORD }}

PROD_PROPERTIES: '${{ secrets.CORE_PROD_PROPERTIES }}'
TEST_PROPERTIES: '${{ secrets.CORE_TEST_PROPERTIES }}'
FIREBASE_KEY: '${{ secrets.FIREBASE_KEY }}'

steps:
- name: Clone Repository
uses: actions/checkout@v4
with:
ref: ${{ env.GIT_REF }}

- name: Generate Version Code
run: |
echo "version=$(date +'%Y%m%d%H%M%S')" >> "$GITHUB_OUTPUT"
echo "VERSION=$(date +'%Y%m%d%H%M%S')" >> $GITHUB_ENV
- name: Setup Docker Registry
uses: docker/login-action@v3
with:
registry: ${{ env.HARBOR_REGISTRY }}
username: ${{ env.HARBOR_USERNAME }}
password: ${{ env.HARBOR_PASSWORD }}

- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: adopt

- name: Cache Gradle Dependencies
uses: actions/cache@v4
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Build with Gradle
run: ./gradlew clean build --exclude-task test

- name: Build and Push Docker Image
uses: docker/build-push-action@v5
with:
file: Dockerfile
context: .
push: true
platforms: linux/amd64
cache-from: type=gha
cache-to: 'type=gha,mode=max'
tags: >
${{ env.HARBOR_REGISTRY }}/${{ env.HARBOR_PROJECT }}/${{ env.HARBOR_REPOSITORY }}:${{ env.VERSION }},
${{ env.HARBOR_REGISTRY }}/${{ env.HARBOR_PROJECT }}/${{ env.HARBOR_REPOSITORY }}:latest
- name: Checkout GitOps Repository
uses: actions/checkout@v4
with:
repository: uoslife/gitops
ref: main
ssh-key: ${{ secrets.GITOPS_SSH_KEY }}
path: gitops

- name: Setup Kustomize
uses: imranismail/setup-kustomize@v2

- name: Update Image Tag
run: |
cd gitops/projects/${{ env.GIT_PROJECT_NAME }}/overlays/${{ inputs.environment }}
kustomize edit set image ${{ env.HARBOR_REPOSITORY }}=${{ env.HARBOR_REGISTRY }}/${{ env.HARBOR_PROJECT }}/${{ env.HARBOR_REPOSITORY }}:${{ env.VERSION }}
- name: Apply Image Tag
run: |
cd gitops/projects/${{ env.GIT_PROJECT_NAME }}/overlays/${{ inputs.environment }}
git config --global user.email ${{ github.actor }}@users.noreply.github.com
git config --global user.name ${{ github.actor }}
git add .
git commit -am "projects(${{ env.GIT_PROJECT_NAME }}): update version to ${{ env.VERSION }}"
git push
48 changes: 0 additions & 48 deletions .github/workflows/dev-validate.yaml

This file was deleted.

66 changes: 0 additions & 66 deletions .github/workflows/test-coverage.yaml

This file was deleted.

6 changes: 0 additions & 6 deletions q

This file was deleted.

0 comments on commit 0c676ef

Please sign in to comment.