Merge remote-tracking branch 'origin/feature/DRAW-275' into sandbox #123
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
name: Deploy-Dev-K8S | |
on: | |
push: | |
branches: | |
- "sandbox" | |
env: | |
REGISTRY_URL: ${{ secrets.REGISTRY_URL }} | |
IMAGE_NAME: ${{ secrets.IMAGE_NAME }} | |
IMAGE_TAG: ${{ github.sha }} | |
jobs: | |
test: | |
name: Test | |
runs-on: ubuntu-latest | |
environment: dev | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v3 | |
with: | |
java-version: '17' | |
distribution: 'adopt' | |
- name: Grant execute permission for gradlew | |
run: chmod +x gradlew | |
- name: Check ktlint format | |
run: ./gradlew clean ktlintCheck | |
- name: Gradle Clean & Build | |
run: ./gradlew clean build | |
- name: Test with Gradle | |
run: ./gradlew test | |
build: | |
name: Build | |
runs-on: ubuntu-latest | |
environment: dev | |
outputs: | |
image: echo ${{ steps.build-image.outputs.image }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Docker Setup QEMU | |
uses: docker/[email protected] | |
- name: Docker Setup Buildx | |
uses: docker/[email protected] | |
- name: Login to Docker Hub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Build Docker image | |
run: | | |
docker build \ | |
--platform linux/arm64 \ | |
--build-arg PHASE=${{ vars.PHASE }} \ | |
-f app/api/Dockerfile \ | |
-t $REGISTRY_URL/$IMAGE_NAME:$IMAGE_TAG . | |
- name: Push Docker image | |
run: docker push $REGISTRY_URL/$IMAGE_NAME:$IMAGE_TAG | |
deploy: | |
name: Deploy | |
runs-on: ubuntu-latest | |
environment: dev | |
needs: | |
- test | |
- build | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
with: | |
repository: ${{ secrets.ARGO_CD_REPO }} | |
ref: dev | |
token: ${{ secrets.TOKEN_GITHUB }} | |
- name: Update YAML file | |
run: | | |
# 변경할 YAML 파일 경로 | |
yaml_file="${{ secrets.ARGO_CD_PATH }}/values.yaml" | |
# 변경할 키와 새 값 | |
key="tag" | |
new_value="$IMAGE_TAG" | |
# sed를 사용하여 키 값 변경 | |
sed -i -E "s/(\s*${key}:\s*).*/\1${new_value}/" $yaml_file | |
echo "Updated $key to $new_value in $yaml_file" | |
cat $yaml_file | |
- name: Commit changes | |
run: | | |
git config --global user.name 'github-actions[bot]' | |
git config --global user.email 'github-actions[bot]@users.noreply.github.com' | |
git add ${{ secrets.ARGO_CD_PATH }}/values.yaml | |
git commit -m "Update YAML file value" | |
git push | |
env: | |
GITHUB_TOKEN: ${{ secrets.TOKEN_GITHUB }} | |