-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
119 additions
and
229 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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
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 |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.