Skip to content

Merge pull request #30 from MJU-InsuranceSystem/feature/reward #41

Merge pull request #30 from MJU-InsuranceSystem/feature/reward

Merge pull request #30 from MJU-InsuranceSystem/feature/reward #41

Workflow file for this run

name: CI script
on:
push:
branches:
- main
jobs:
build_and_push:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
- name: make application.yml
run: |
cd ./src/main/resources
touch ./application.yml
echo "${{ secrets.YML }}" > ./application.yml
shell: bash
- name: make application-prod.yml
run: |
cd ./src/main/resources
touch ./application-prod.yml
echo "${{ secrets.PROD_YML }}" > ./application-prod.yml
shell: bash
- name: Setup Gradle
uses: gradle/actions/setup-gradle@af1da67850ed9a4cedd57bfd976089dd991e2582 # v4.0.0
- name: Build with Gradle Wrapper
run: ./gradlew clean build
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.DEV_AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.DEV_AWS_SECRET_ACCESS_KEY }}
aws-region: us-east-1
- name: Login to Amazon ECR Public
id: login-ecr-public
uses: aws-actions/amazon-ecr-login@v2
with:
registry-type: public
- name: Delete previous image in Amazon ECR Public
env:
REGISTRY_ALIAS: ${{ secrets.DEV_ECR_REGISTRY_ALIAS }}
REPOSITORY: distribute/dev
run: |
aws ecr-public batch-delete-image \
--repository-name distribute/dev \
--image-ids imageTag=latest \
--region us-east-1 || echo "No existing image with tag latest found."
- name: Build, tag, and push docker image to Amazon ECR Public
env:
REGISTRY: ${{ steps.login-ecr-public.outputs.registry }}
REGISTRY_ALIAS: ${{ secrets.DEV_ECR_REGISTRY_ALIAS }}
REPOSITORY: distribute/dev
IMAGE_TAG: latest
run: |
echo "REPOSITORY: $REPOSITORY"
docker build -t $REGISTRY/$REGISTRY_ALIAS/$REPOSITORY:$IMAGE_TAG .
docker push $REGISTRY/$REGISTRY_ALIAS/$REPOSITORY:$IMAGE_TAG
echo "::set-output name=image::$REGISTRY/$REGISTRY_ALIAS/$REPOSITORY:$IMAGE_TAG"
- name: Logout of Amazon ECR
run: docker logout ${{ env.ECR_REGISTRY }}