Skip to content

chore: skip test jar, just assemble #3

chore: skip test jar, just assemble

chore: skip test jar, just assemble #3

Workflow file for this run

name: build and deploy (Production)
on:
push:
branches:
- main
env:
IMAGE_TAG: legacy-prod${{ github.run_number }}
ECR_REPOSITORY: meal-backend
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
outputs:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
ECR_REPOSITORY: ${{ env.ECR_REPOSITORY }}
IMAGE_TAG: ${{ env.IMAGE_TAG }}
steps:
- uses: actions/checkout@v4
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ap-northeast-2
mask-aws-account-id: no
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v3
- name: Build with Gradle Wrapper
run: ./gradlew assemble
- name: Build, tag, and push image to Amazon ECR
uses: docker/build-push-action@v2
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
ECR_REPOSITORY: ${{ env.ECR_REPOSITORY }}
IMAGE_TAG: ${{ env.IMAGE_TAG }}
with:
context: .
push: true
tags: ${{ env.ECR_REGISTRY }}/${{ env.ECR_REPOSITORY }}:${{ env.IMAGE_TAG }}
cache-from: type=gha
cache-to: type=gha,mode=max
deploy:
name: Update Git Repository
needs: build
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
repository: gsainfoteam/icarus-gitops
ssh-key: ${{ secrets.SSH_PRIVATE_KEY }}
fetch-depth: 0
- name: Update Kubernetes Manifest
env:
ECR_REGISTRY: ${{ needs.build.outputs.ECR_REGISTRY }}
ECR_REPOSITORY: ${{ needs.build.outputs.ECR_REPOSITORY }}
IMAGE_TAG: ${{ needs.build.outputs.IMAGE_TAG }}
run: |
sed -i "s|image:.*|image: $ECR_REGISTRY\/$ECR_REPOSITORY:$IMAGE_TAG|g" infoteam/service/meal/legacy-prod.yaml
- name: Commit and Push
env:
ECR_REPOSITORY: ${{ needs.build.outputs.ECR_REPOSITORY }}
IMAGE_TAG: ${{ needs.build.outputs.IMAGE_TAG }}
run: |
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --global user.name "GitHub Actions"
git commit -am "Update image $ECR_REPOSITORY:$IMAGE_TAG"
git push -u origin master