Skip to content

Commit

Permalink
chore: add prod-build (#57)
Browse files Browse the repository at this point in the history
* chore: add prod-build

* chore: modify jdk version

* chore: add _PROD postfix in env

* Update prod-build.yaml
  • Loading branch information
jhhong0509 authored Jun 24, 2022
1 parent 1a4980f commit 12fd62e
Showing 1 changed file with 78 additions and 0 deletions.
78 changes: 78 additions & 0 deletions .github/workflows/prod-build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
name: Build for Prod
on:
push:
tags:
- v*.*.*

env:
SERVICE_NAME: user
SERVICE_TYPE: be

jobs:
build:
environment: prod
runs-on: ubuntu-latest
strategy:
matrix:
java-version: [ 17 ]
outputs:
version: ${{ steps.get_version.outputs.BRANCH_NAME }}

steps:
- name: Check Out The Repository
uses: actions/checkout@v3

- name: Set up Java
uses: actions/setup-java@v2
with:
java-version: ${{ matrix.java-version }}
distribution: 'zulu'

- name: Get the version
id: get_version
run: echo ::set-output name=VERSION::$(echo $GITHUB_REF | cut -d / -f 3)

- name: Gradle Build
uses: gradle/gradle-build-action@v2
with:
arguments: |
build
--no-daemon
- name: Log in to Docker Hub
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
with:
username: ${{secrets.DOCKER_USER}}
password: ${{secrets.DOCKER_HUB_TOKEN}}

- name: Build and push Docker image
id: docker_build
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
with:
context: .
file: ./Dockerfile
push: true
tags: ${{secrets.DOCKER_USER}}/${{env.SERVICE_NAME}}-${{env.SERVICE_TYPE}}:${{ steps.get_version.outputs.VERSION }}
build-args: |
DBMS=${{secrets.DBMS_PROD}}
DB_HOST=${{secrets.DB_HOST_PROD}}
DB_PORT=${{secrets.DB_PORT_PROD}}
DB_NAME=${{secrets.DB_NAME_PROD}}
DB_PASSWORD=${{secrets.DB_PASSWORD_PROD}}
DB_USERNAME=${{secrets.DB_USERNAME_PROD}}
SHOW_SQL=${{secrets.SHOW_SQL_PROD}}
DDL_AUTO_MODE=${{secrets.DDL_AUTO_MODE_PROD}}
DB_POOL=${{secrets.DB_POOL_PROD}}
AUTHORITY_SERVICE_HOST=${{secrets.AUTHORITY_SERVICE_HOST}}
- name: Repository Dispatch
uses: peter-evans/repository-dispatch@v1
with:
token: ${{ secrets.GITOPS_DEPLOY_PRODUCTION_TOKEN }}
repository: team-xquare/xquare-gitops-repo-production
event-type: update_image
client-payload: '{
"ref": "${{ github.ref }}",
"version": "${{ steps.get_version.outputs.VERSION }}",
"service_name": "${{env.SERVICE_NAME}}",
"service_type": "${{env.SERVICE_TYPE}}"
}'

0 comments on commit 12fd62e

Please sign in to comment.