π· CI Workflow #1
Workflow file for this run
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: Continuous Integration | |
on: | |
push: | |
branches: [main] | |
pull_request: | |
branches: [main] | |
env: | |
AWS_REGION: ap-northeast-2 | |
ECR_REPOSITORY: threedays-app | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up JDK 21 | |
uses: actions/setup-java@v4 | |
with: | |
java-version: '21' | |
distribution: 'liberica' | |
- name: Cache Gradle packages | |
uses: actions/cache@v4 | |
with: | |
path: ~/.gradle/caches | |
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }} | |
restore-keys: ${{ runner.os }}-gradle | |
- name: Configure AWS credentials | |
uses: aws-actions/configure-aws-credentials@v2 | |
with: | |
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
aws-region: ap-northeast-2 | |
- name: Login to Amazon ECR | |
id: login-ecr | |
uses: aws-actions/amazon-ecr-login@v2 | |
- name: Build and push image to Amazon ECR | |
env: | |
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} | |
IMAGE_TAG: ${{ github.sha }} | |
run: | | |
./gradlew jib \ | |
-Djib.to.image=$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG \ | |
-Djib.to.tags=latest \ | |
-Djib.to.auth.username=${{ secrets.AWS_ACCESS_KEY_ID }} \ | |
-Djib.to.auth.password=${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
- name: Save image info | |
run: | | |
echo "${{ steps.login-ecr.outputs.registry }}/$ECR_REPOSITORY:${{ github.sha }}" > image_info.txt | |
- name: Upload artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: image-info | |
path: image_info.txt |