Merge pull request #81 from Final-Project-Team-Temporary/feature/사용자-… #40
This file contains hidden or 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: ci.yml | |
| on: | |
| workflow_dispatch: | |
| push: | |
| branches: [ develop ] | |
| paths-ignore: | |
| - '.github/workflows/cd.yml' # 워크플로우 수정만 있을 때는 빌드 스킵 | |
| - 'README.md' | |
| jobs: | |
| # 1. 빌드 + 이미지 빌드 & 푸시 | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Decode and export env vars | |
| run: | | |
| echo "${{ secrets.APP_ENV_B64 }}" | base64 --decode | tr -d '\r'> .env | |
| # .env 내용을 GitHub Actions 환경변수로 export | |
| while IFS='=' read -r key value; do | |
| if [[ ! -z "$key" && ! "$key" =~ ^# ]]; then | |
| echo "$key=$value" >> $GITHUB_ENV | |
| fi | |
| done < .env | |
| - name: Check out code | |
| uses: actions/checkout@v3 | |
| - name: Set up JDK 17 | |
| uses: actions/setup-java@v3 | |
| with: | |
| distribution: 'temurin' | |
| java-version: '17' | |
| cache: 'gradle' | |
| - name: Build (no Test) | |
| run: ./gradlew clean bootJar --no-daemon | |
| - name: Configure AWS credentials | |
| uses: aws-actions/configure-aws-credentials@v4 | |
| with: | |
| aws-access-key-id: ${{ env.AWS_ACCESS_KEY_ID }} | |
| aws-secret-access-key: ${{ env.AWS_SECRET_ACCESS_KEY }} | |
| aws-region: ${{ env.AWS_REGION }} | |
| - name: Log in to Amazon ECR | |
| id: login-ecr | |
| uses: aws-actions/amazon-ecr-login@v2 | |
| - name: Build, tag, and push image to Amazon ECR | |
| env: | |
| ECR_REGISTRY: ${{ env.ECR_REGISTRY }} | |
| ECR_REPOSITORY: ${{ env.ECR_REPOSITORY }} | |
| IMAGE_TAG: ${{ github.sha }} | |
| run: | | |
| echo "tag: $IMAGE_TAG" | |
| docker buildx build \ | |
| --platform linux/amd64 \ | |
| -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG \ | |
| -t $ECR_REGISTRY/$ECR_REPOSITORY:latest \ | |
| --push . | |
| # 태그관리: latest, github hash |