Skip to content

Merge pull request #176 from Media-XI/develop #96

Merge pull request #176 from Media-XI/develop

Merge pull request #176 from Media-XI/develop #96

Workflow file for this run

name: Docker Prod CI
on:
push:
branches: [ "main" ]
env:
# Use docker.io for Docker Hub if empty
REGISTRY: docker.io
# github.repository as <account>/<repo>
IMAGE_NAME: shonn/art-be
DOCKER_REGISTRY_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKER_REGISTRY_PASSWORD: ${{ secrets.DOCKERHUB_PASSWORD }}
JASYPT_ENCRYPTOR_PASSWORD: ${{ secrets.JASYPT_ENCRYPTOR_PASSWORD }}
AWS_S3_BUCKET_NAME: ${{ secrets.AWS_S3_BUCKET_NAME }}
AWS_CODE_DEPLOY_NAME: artscope-codedeploy
AWS_CODE_DEPLOY_GROUP: artscope-codedeploy-group
SENTRY_DSN: ${{ secrets.SENTRY_DSN }}
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
jobs:
build-dockerized-production:
name: Build and push Docker image
runs-on: ubuntu-latest
services:
redis:
image: redis
ports:
- 16379:6379
steps:
- uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
- name: Cache Gradle packages
uses: actions/cache@v2
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Grant execute permission for gradlew
run: chmod +x ./gradlew
- name: Build with Gradle
uses: gradle/gradle-build-action@v2.4.2
with:
arguments: |
build
- name: Setup Docker buildx
uses: docker/setup-buildx-action@79abd3f86f79a9d68a23c75a09a9a85889262adf
- name: Set Docker Image Name (Build Info)
run: echo "DOCKER_IMAGE_NAME=${{ env.IMAGE_NAME }}:${{ secrets.MAJOR }}.${{ secrets.MINOR }}" >> $GITHUB_ENV
- name: Build the Docker image
run: docker build --tag ${{ env.DOCKER_IMAGE_NAME }} --build-arg BUILD_INFO=${{ env.DOCKER_IMAGE_NAME }} -f Dockerfile.prod .
- name: Login to registry ${{ env.REGISTRY }}
run: echo "$DOCKER_REGISTRY_PASSWORD" | docker login "$REGISTRY" -u "$DOCKER_REGISTRY_USERNAME" --password-stdin
- name: Push to ${{ env.REGISTRY }}
run: docker push ${{ env.DOCKER_IMAGE_NAME }}
# 다음 버전으로 업데이트
- name: Autoincrement a new minor version
run: |
echo "NEW_MINOR_VERSION=$((${{ secrets.MINOR }}+1))" >> $GITHUB_ENV
- name: Update Minor version
uses: hmanzur/actions-set-secret@v2.0.0
with:
name: 'MINOR'
value: ${{ env.NEW_MINOR_VERSION }}
repository: ${{ secrets.REPO }}
token: ${{ secrets.REPO_ACCESS_TOKEN }}