Skip to content

Fix: Member 회사 정보와 email 로 값 변환 하게 수정 #39

Fix: Member 회사 정보와 email 로 값 변환 하게 수정

Fix: Member 회사 정보와 email 로 값 변환 하게 수정 #39

Workflow file for this run

name: Build Spring Application and Push to ECR
on:
push:
branches:
- main
jobs:
build:
runs-on: ubuntu-latest
outputs:
image_tag: ${{ steps.get_version.outputs.version }}
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
distribution: "temurin"
java-version: '17'
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Build Spring Application with Secrets
env:
SPRING_DATASOURCE_URL: ${{ secrets.SPRING_DATASOURCE_URL }}
SPRING_DATASOURCE_USERNAME: ${{ secrets.SPRING_DATASOURCE_USERNAME }}
SPRING_DATASOURCE_PASSWORD: ${{ secrets.SPRING_DATASOURCE_PASSWORD }}
run: ./gradlew clean bootJar
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v2
with:
aws-access-key-id: ${{ secrets.INFRA_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.INFRA_SECRET_ACCESS_KEY }}
aws-region: ap-northeast-2
- name: Log in to Amazon ECR
run: aws ecr get-login-password --region ap-northeast-2 | docker login --username AWS --password-stdin "${{ secrets.AWS_ACCOUNT_ID }}.dkr.ecr.ap-northeast-2.amazonaws.com"
- name: Generate image tag
id: get_version
run: echo "version=$(date +'%Y%m%d-%H%M%S')" >> $GITHUB_OUTPUT
- name: Build and Push Docker Image
env:
ECR_REGISTRY: ${{ secrets.AWS_ACCOUNT_ID }}.dkr.ecr.ap-northeast-2.amazonaws.com
ECR_REPOSITORY: aiwa-project/member
IMAGE_TAG: ${{ steps.get_version.outputs.version }}
run: |
docker build \
--build-arg AWS_ACCESS_KEY_ID=${{ secrets.AWS_ACCESS_KEY_ID }} \
--build-arg AWS_SECRET_ACCESS_KEY=${{ secrets.AWS_SECRET_ACCESS_KEY }} \
--build-arg SPRING_DATASOURCE_URL="${{ secrets.SPRING_DATASOURCE_URL }}" \
--build-arg SPRING_DATASOURCE_USERNAME="${{ secrets.SPRING_DATASOURCE_USERNAME }}" \
--build-arg SPRING_DATASOURCE_PASSWORD="${{ secrets.SPRING_DATASOURCE_PASSWORD }}" \
-t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG \
-t $ECR_REGISTRY/$ECR_REPOSITORY:latest \
. && \
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG && \
docker push $ECR_REGISTRY/$ECR_REPOSITORY:latest
- name: Checkout Helm chart repository
uses: actions/checkout@v3
with:
repository: AWS-Cloud-School-6/AIWA-MCP-Helm
path: AIWA-MCP-Helm
token: ${{ secrets.PAT_AIWA_MEMBER_TOKEN }}
- name: Update Helm chart
run: |
cd AIWA-MCP-Helm/aiwa-member
if [ ! -f values.yaml ]; then
echo "Error: values.yaml not found in $(pwd)"
exit 1
fi
sed -i "s|tag: .*|tag: \"${{ steps.get_version.outputs.version }}\"|" values.yaml
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add values.yaml
if git diff --staged --quiet; then
echo "No changes to commit in values.yaml"
else
git commit -m "Update image tag to ${{ steps.get_version.outputs.version }}"
git push || { echo "Failed to push changes"; exit 2; }
fi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}