Skip to content

[Fix] redis 제거

[Fix] redis 제거 #89

Workflow file for this run

name: Build and Trigger Azure DevOps Pipeline
# Controls when the workflow will run
on:
# Triggers the 'Deploy' workflow after the push but only for the master branch - (instead of Pull Request)
push:
branches: [ "master" ]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
permissions:
contents: read
id-token: write
# Setting environment values
env:
# AZURE 관 환경변수
AZURE_DEVOPS_ORG: "${{ secrets.AZURE_DEVOPS_ORGANICATION }}"
AZURE_DEVOPS_PROJECT: "${{ secrets.AZURE_DEVOPS_PROJECT }}"
AZURE_DEVOPS_PAT: "${{ secrets.AZURE_DEVOPS_PAT }}"
AZURE_CLIENT_ID: "${{ secrets.AZURE_CLIENT_ID }}"
AZURE_CLIENT_SECRET: "${{ secrets.AZURE_CLIENT_SECRET }}"
AZURE_TENANT_ID: "${{ secrets.AZURE_TENANT_ID }}"
AZURE_STORAGE_ACCOUNT_NAME: "${{ secrets.AZURE_STORAGE_ACCOUNT_NAME }}"
AZURE_STORAGE_ACCOUNT_KEY: "${{ secrets.AZURE_STORAGE_ACCOUNT_KEY }}"
AZURE_STORAGE_CONTAINER_NAME: "${{ secrets.AZURE_STORAGE_CONTAINER_NAME }}"
# APP 관련 환경변수
MYSQL_ROOT_PWD: ${{ secrets.MYSQL_ROOT_PWD }}
MYSQL_DB: ${{ secrets.MYSQL_DB }}
MYSQL_HOST: ${{ secrets.MYSQL_HOST }}
REDIS_HOST: ${{ secrets.REDIS_HOST }}
jobs:
build-and-upload:
runs-on: ubuntu-latest
environment: production
services:
mysql:
image: mysql:8.0.37
ports:
- 3306:3306
options: >-
--health-cmd="mysqladmin ping --silent"
--health-interval=10s
--health-timeout=5s
--health-retries=3
env:
MYSQL_ROOT_PASSWORD: ${{ env.MYSQL_ROOT_PWD }}
MYSQL_DATABASE: ${{ env.MYSQL_DB }}
# redis:
# image: redis:7.0.15
# ports:
# - 6379:6379
# options: >-
# --health-cmd="redis-cli ping"
# --health-interval=10s
# --health-timeout=5s
# --health-retries=3
steps:
# Step 1: 저장소 클론 및 의존성 설치
- name: Checkout Repository
uses: actions/checkout@v3
# (2) JDK 17 세팅 (v1->v3)
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'adopt'
# (3) Gradle 권한설정
- 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
shell: bash
# # (4) Redis 설치
# - name: Install redis-cli
# run: sudo apt-get update && sudo apt-get install -y redis-tools
# (5) Mysql 세팅 대기
- name: Wait for MySQL
run: |
until mysqladmin ping -h ${{ env.MYSQL_HOST }} --silent; do
echo 'waiting for mysql to be connectable...'
sleep 5
done
# # (6) Redis 세팅 대기
# - name: Wait for Redis
# run: |
# until redis-cli -h ${{ env.REDIS_HOST }} ping; do
# echo 'waiting for redis to be connectable...'
# sleep 5
# done
# (7) Gradle build (Test 제외)
- name: Build with Gradle
run: ./gradlew build -x test
shell: bash
# (8) 빌드된 파일 및 전체 레포지토리를 아카이브로 압축
- name: Archive files
run: |
mkdir -p artifacts
zip -r artifacts/repository.zip .
# (9) azure blob에 업로드
# 1. Azure CLI 설정
- name: Install azure-cli
uses: pietrobolcato/[email protected]
# 2. Azure 로그인
- name: Log in to Azure
run: |
az login --service-principal --username ${{ env.AZURE_CLIENT_ID }} --password ${{ env.AZURE_CLIENT_SECRET }} --tenant ${{ env.AZURE_TENANT_ID }}
# 기존 파일 삭제
- name: Clear folder in Azure Blob Storage
run: |
az storage blob delete-batch \
--account-name ${{ env.AZURE_STORAGE_ACCOUNT_NAME }} \
--account-key ${{ env.AZURE_STORAGE_ACCOUNT_KEY }} \
--source ${{ env.AZURE_STORAGE_CONTAINER_NAME }} \
--pattern "*"
# 5. Azure Blob Storage에 파일 업로드
- name: Upload file to Azure Blob Storage
run: |
az storage blob upload \
--account-name ${{ env.AZURE_STORAGE_ACCOUNT_NAME }} \
--account-key ${{ env.AZURE_STORAGE_ACCOUNT_KEY }} \
--container-name ${{ env.AZURE_STORAGE_CONTAINER_NAME }} \
--file artifacts/repository.zip \
--name repository.zip
- name: Azure Pipelines Action
uses: Azure/[email protected]
with:
azure-devops-project-url: 'https://dev.azure.com/${{ env.AZURE_DEVOPS_ORG }}/${{ env.AZURE_DEVOPS_PROJECT }}'
azure-pipeline-name: 'Likelion-Inner-Join.Backend' # name of the Azure pipeline to be triggered
azure-devops-token: '${{ env.AZURE_DEVOPS_PAT }}'
azure-pipeline-variables: '{"filename": "repository.zip"}' # optional stringified json