Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: dev 워크플로 추가 #34

Merged
merged 4 commits into from
Jul 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 77 additions & 0 deletions .github/workflows/api-gateway-dev.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
name: API 게이트웨이 DEV 빌드 후 도커허브에 올리기
on:
push:
branches: [ 'dev' ]
paths:
- 'api-gateway/**' # API Gateway 모듈 변경
- '.github/workflows/api-gateway-dev.yaml' # API Gateway 워크플로우 변경

env:
SPRING_PROFILE: dev
IMAGE_NAME: spinachpasta/api-gateway-dev
MODULE_PATH: api-gateway
SERVER_PORT: 8080
GIT_ENVIRONMENT: dev (api-gateway)

concurrency:
group: api-gateway

jobs:
prepare-variables:
name: 환경변수 준비하기
runs-on: ubuntu-latest
outputs:
image-tag: ${{ steps.setup-env.outputs.image-tag }}
module-path: ${{ steps.setup-env.outputs.module-path }}
spring-profile: ${{ steps.setup-env.outputs.spring-profile }}
server-port: ${{ steps.setup-env.outputs.server-port }}
image-name: ${{ steps.setup-env.outputs.image-name }}
git-environment: ${{ steps.setup-env.outputs.git-environment }}
steps:
- name: GitHub 에서 레포 받아오기
uses: actions/checkout@v3

- name: 환경변수 출력하기
id: setup-env
run: |
echo "image-tag=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
echo "module-path=$MODULE_PATH" >> $GITHUB_OUTPUT
echo "spring-profile=$SPRING_PROFILE" >> $GITHUB_OUTPUT
echo "server-port=$SERVER_PORT" >> $GITHUB_OUTPUT
echo "image-name=$IMAGE_NAME" >> $GITHUB_OUTPUT
echo "git-environment=$GIT_ENVIRONMENT" >> $GITHUB_OUTPUT

call-build-workflow:
if: github.event_name == 'push'
needs: [ prepare-variables ]
name: 이미지 빌드 & 푸쉬
uses: ./.github/workflows/jib-build.yaml
permissions:
id-token: write
contents: read
with:
spring-profile: ${{ needs.prepare-variables.outputs.spring-profile }}
server-port: ${{ needs.prepare-variables.outputs.server-port }}
image-name: ${{ needs.prepare-variables.outputs.image-name }}
image-tag: ${{ needs.prepare-variables.outputs.image-tag }}
module-path: ${{ needs.prepare-variables.outputs.module-path }}
secrets:
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}

call-deploy-workflow:
needs: [ prepare-variables, call-build-workflow ]
name: ArgoCD로 배포하기
uses: ./.github/workflows/argocd-deploy.yaml
permissions:
contents: write
with:
argocd-repo-name: YAPP-Github/mafoo-argocd-manifest
overlay-name: ${{ needs.prepare-variables.outputs.spring-profile }}
service-name: ${{ needs.prepare-variables.outputs.module-path }}
image-name: ${{ needs.prepare-variables.outputs.image-name }}
image-tag: ${{ needs.prepare-variables.outputs.image-tag }}
environment: ${{ needs.prepare-variables.outputs.git-environment }}
default-image-name: spinachpasta/api-gateway
secrets:
PAT_TOKEN: ${{ secrets.PAT_TOKEN }}
1 change: 1 addition & 0 deletions .github/workflows/api-gateway.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -72,5 +72,6 @@ jobs:
image-name: ${{ needs.prepare-variables.outputs.image-name }}
image-tag: ${{ needs.prepare-variables.outputs.image-tag }}
environment: ${{ needs.prepare-variables.outputs.git-environment }}
default-image-name: spinachpasta/api-gateway
secrets:
PAT_TOKEN: ${{ secrets.PAT_TOKEN }}
6 changes: 5 additions & 1 deletion .github/workflows/argocd-deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ on:
service-name:
required: true
type: string
default-image-name:
required: true
type: string
image-name:
required: true
type: string
Expand Down Expand Up @@ -44,9 +47,10 @@ jobs:
- name: 이미지 태그 변경 후 배포하기
run: |
cd modules/${{ inputs.service-name }}/overlays/${{ inputs.overlay-name }}
kustomize edit set image ${{ inputs.image-name }}:${{ inputs.image-tag }}
kustomize edit set image ${{ inputs.default-image-name }}=${{ inputs.image-name }}:${{ inputs.image-tag }}
cat kustomization.yaml
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
git commit -am "release(${{ inputs.service-name }}): 자동배포 ${{ inputs.image-name }}:${{ inputs.image-tag }}"
git config pull.rebase true
git pull && git push -u origin main
78 changes: 78 additions & 0 deletions .github/workflows/photo-service-dev.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
name: 사진 서비스 DEV 빌드 후 도커허브에 올리기
on:
push:
branches: [ 'dev' ]
paths:
- 'photo-service/**' # Photo Service 모듈 변경
- '.github/workflows/photo-service-dev.yaml' # Photo Service 워크플로우 변경

env:
SPRING_PROFILE: dev
IMAGE_NAME: spinachpasta/photo-service-dev
MODULE_PATH: photo-service
SERVER_PORT: 8080
GIT_ENVIRONMENT: dev (photo-service)

concurrency:
group: photo-service

jobs:
prepare-variables:
name: 환경변수 준비하기
runs-on: ubuntu-latest
outputs:
image-tag: ${{ steps.setup-env.outputs.image-tag }}
module-path: ${{ steps.setup-env.outputs.module-path }}
spring-profile: ${{ steps.setup-env.outputs.spring-profile }}
server-port: ${{ steps.setup-env.outputs.server-port }}
image-name: ${{ steps.setup-env.outputs.image-name }}
git-environment: ${{ steps.setup-env.outputs.git-environment }}
steps:
- name: GitHub 에서 레포 받아오기
uses: actions/checkout@v3

- name: 환경변수 출력하기
id: setup-env
run: |
echo "image-tag=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
echo "module-path=$MODULE_PATH" >> $GITHUB_OUTPUT
echo "spring-profile=$SPRING_PROFILE" >> $GITHUB_OUTPUT
echo "server-port=$SERVER_PORT" >> $GITHUB_OUTPUT
echo "image-name=$IMAGE_NAME" >> $GITHUB_OUTPUT
echo "git-environment=$GIT_ENVIRONMENT" >> $GITHUB_OUTPUT

call-build-workflow:
if: github.event_name == 'push'
needs: [ prepare-variables ]
name: 이미지 빌드 & 푸쉬
uses: ./.github/workflows/jib-build.yaml
permissions:
id-token: write
contents: read
with:
spring-profile: ${{ needs.prepare-variables.outputs.spring-profile }}
server-port: ${{ needs.prepare-variables.outputs.server-port }}
image-name: ${{ needs.prepare-variables.outputs.image-name }}
image-tag: ${{ needs.prepare-variables.outputs.image-tag }}
module-path: ${{ needs.prepare-variables.outputs.module-path }}
secrets:
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}


call-deploy-workflow:
needs: [ prepare-variables, call-build-workflow ]
name: ArgoCD로 배포하기
uses: ./.github/workflows/argocd-deploy.yaml
permissions:
contents: write
with:
argocd-repo-name: YAPP-Github/mafoo-argocd-manifest
overlay-name: ${{ needs.prepare-variables.outputs.spring-profile }}
service-name: ${{ needs.prepare-variables.outputs.module-path }}
image-name: ${{ needs.prepare-variables.outputs.image-name }}
image-tag: ${{ needs.prepare-variables.outputs.image-tag }}
environment: ${{ needs.prepare-variables.outputs.git-environment }}
default-image-name: spinachpasta/photo-service
secrets:
PAT_TOKEN: ${{ secrets.PAT_TOKEN }}
1 change: 1 addition & 0 deletions .github/workflows/photo-service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -73,5 +73,6 @@ jobs:
image-name: ${{ needs.prepare-variables.outputs.image-name }}
image-tag: ${{ needs.prepare-variables.outputs.image-tag }}
environment: ${{ needs.prepare-variables.outputs.git-environment }}
default-image-name: spinachpasta/photo-service
secrets:
PAT_TOKEN: ${{ secrets.PAT_TOKEN }}
78 changes: 78 additions & 0 deletions .github/workflows/user-service-dev.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
name: 유저 서비스 DEV 빌드 후 도커허브에 올리기
on:
push:
branches: [ 'dev' ]
paths:
- 'user-service/**' # User Service 모듈 변경
- '.github/workflows/user-service-dev.yaml' # User Service 워크플로우 변경

env:
SPRING_PROFILE: dev
IMAGE_NAME: spinachpasta/user-service-dev
MODULE_PATH: user-service
SERVER_PORT: 8080
GIT_ENVIRONMENT: dev (user-service)

concurrency:
group: user-service

jobs:
prepare-variables:
name: 환경변수 준비하기
runs-on: ubuntu-latest
outputs:
image-tag: ${{ steps.setup-env.outputs.image-tag }}
module-path: ${{ steps.setup-env.outputs.module-path }}
spring-profile: ${{ steps.setup-env.outputs.spring-profile }}
server-port: ${{ steps.setup-env.outputs.server-port }}
image-name: ${{ steps.setup-env.outputs.image-name }}
git-environment: ${{ steps.setup-env.outputs.git-environment }}
steps:
- name: GitHub 에서 레포 받아오기
uses: actions/checkout@v3

- name: 환경변수 출력하기
id: setup-env
run: |
echo "image-tag=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
echo "module-path=$MODULE_PATH" >> $GITHUB_OUTPUT
echo "spring-profile=$SPRING_PROFILE" >> $GITHUB_OUTPUT
echo "server-port=$SERVER_PORT" >> $GITHUB_OUTPUT
echo "image-name=$IMAGE_NAME" >> $GITHUB_OUTPUT
echo "git-environment=$GIT_ENVIRONMENT" >> $GITHUB_OUTPUT

call-build-workflow:
if: github.event_name == 'push'
needs: [ prepare-variables ]
name: 이미지 빌드 & 푸쉬
uses: ./.github/workflows/jib-build.yaml
permissions:
id-token: write
contents: read
with:
spring-profile: ${{ needs.prepare-variables.outputs.spring-profile }}
server-port: ${{ needs.prepare-variables.outputs.server-port }}
image-name: ${{ needs.prepare-variables.outputs.image-name }}
image-tag: ${{ needs.prepare-variables.outputs.image-tag }}
module-path: ${{ needs.prepare-variables.outputs.module-path }}
secrets:
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}


call-deploy-workflow:
needs: [ prepare-variables, call-build-workflow ]
name: ArgoCD로 배포하기
uses: ./.github/workflows/argocd-deploy.yaml
permissions:
contents: write
with:
argocd-repo-name: YAPP-Github/mafoo-argocd-manifest
overlay-name: ${{ needs.prepare-variables.outputs.spring-profile }}
service-name: ${{ needs.prepare-variables.outputs.module-path }}
image-name: ${{ needs.prepare-variables.outputs.image-name }}
image-tag: ${{ needs.prepare-variables.outputs.image-tag }}
environment: ${{ needs.prepare-variables.outputs.git-environment }}
default-image-name: spinachpasta/user-service
secrets:
PAT_TOKEN: ${{ secrets.PAT_TOKEN }}
1 change: 1 addition & 0 deletions .github/workflows/user-service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -73,5 +73,6 @@ jobs:
image-name: ${{ needs.prepare-variables.outputs.image-name }}
image-tag: ${{ needs.prepare-variables.outputs.image-tag }}
environment: ${{ needs.prepare-variables.outputs.git-environment }}
default-image-name: spinachpasta/user-service
secrets:
PAT_TOKEN: ${{ secrets.PAT_TOKEN }}
Loading