feat: ownerPermission (#25) #37
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: Deploy Staging Image | |
on: | |
workflow_dispatch: | |
push: | |
branches: | |
- main | |
paths: | |
- 'src/**' | |
env: | |
AWS_REGION: us-west-2 | |
ECR_REPOSITORY: 992382730467.dkr.ecr.us-west-2.amazonaws.com/staging-kogo-content-backend | |
ACTIVE_PROFILE: stg | |
jobs: | |
deploy-staging: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Code | |
uses: actions/checkout@v3 | |
- uses: actions/setup-java@v3 | |
with: | |
distribution: temurin | |
java-version: 21 | |
- name: Setup AWS CLI | |
uses: aws-actions/configure-aws-credentials@v1 | |
with: | |
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
aws-region: ${{ env.AWS_REGION }} | |
- name: Login to Amazon ECR | |
id: ecr_login | |
uses: aws-actions/amazon-ecr-login@v1 | |
- name: Generate Timestamp | |
id: timestamp | |
run: echo "TIMESTAMP=$(date +'%Y%m%d-%H%M%S')" >> $GITHUB_ENV | |
- name: Extract KCB_VERSION from build.gradle.kts | |
id: extract_version | |
run: | | |
VERSION=$(grep "^version" build.gradle.kts | sed 's/version = "\(.*\)"/\1/') | |
echo "KCB_VERSION=$VERSION" >> $GITHUB_ENV | |
- name: Build with Gradle (stg profile) | |
run: ./gradlew clean build -x test | |
- name: Build Docker image | |
run: | | |
COMMIT_HASH=${{ github.sha }} | |
docker build \ | |
--build-arg KCB_VERSION=${{ env.KCB_VERSION }} \ | |
--build-arg ACTIVE_PROFILE=${{ env.ACTIVE_PROFILE }} \ | |
--build-arg AWS_ACCESS_KEY_ID=${{ env.AWS_ACCESS_KEY_ID }} \ | |
--build-arg AWS_SECRET_ACCESS_KEY=${{ env.AWS_SECRET_ACCESS_KEY }} \ | |
--build-arg AWS_REGION=${{ env.AWS_REGION }} \ | |
-t ${{ env.ECR_REPOSITORY }}:latest \ | |
-t ${{ env.ECR_REPOSITORY }}:${{ env.TIMESTAMP }}-${COMMIT_HASH::7} \ | |
. | |
- name: Push Docker images to ECR | |
run: | | |
docker push ${{ env.ECR_REPOSITORY }} --all-tags | |
- name: Run App Runner Deployment | |
run: ./bin/deploy-apprunner-stg.sh --auto |