[Refactor] MainPageController 클래스명 변경 #22
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: CI/CD test | |
on: | |
pull_request_target: | |
types: [closed] | |
jobs: | |
build: | |
environment: aws | |
if: github.event.pull_request.merged == true && github.event.pull_request.base.ref == 'develop' | |
runs-on: ubuntu-latest | |
permissions: | |
id-token: write | |
contents: read | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v4 | |
with: | |
java-version: '17' | |
distribution: 'oracle' | |
- name: echo test | |
run: | | |
echo "EC2_PUBLIC_IP: ${{ secrets.EC2_PUBLIC_IP }}" | |
echo "DB_USERNAME: ${{ secrets.DB_USERNAME }}" | |
- name: Setup SSH | |
uses: webfactory/[email protected] | |
with: | |
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }} | |
- name: Add SSH Host to known_hosts | |
run: | | |
mkdir -p ~/.ssh | |
ssh-keyscan -H ${{ secrets.EC2_PUBLIC_IP }} >> ~/.ssh/known_hosts | |
- name: Create SSH Tunnel | |
run: | | |
${{ secrets.TUNNEL_SCRIPT }} | |
- name: Run Database Tests | |
env: | |
MYSQL_PWD: ${{ secrets.DB_PASSWORD }} | |
run: | | |
mysql -h 127.0.0.1 -P 3307 -u ${{ secrets.DB_USERNAME }} -e "SHOW DATABASES;" | |
- name: Start Redis | |
uses: supercharge/[email protected] | |
with: | |
redis-version: 6 | |
- name: Install Redis CLI | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y redis-tools | |
- name: Check Redis status | |
run: | | |
redis-cli -h 127.0.0.1 -p 6379 ping | |
- name: Set environment variables | |
run: | | |
echo "REDIS_HOST=${{ secrets.REDIS_HOST }}" >> $GITHUB_ENV | |
echo "REDIS_PORT=${{ secrets.REDIS_PORT }}" >> $GITHUB_ENV | |
echo "DB_URL=${{ secrets.DB_URL }}" >> $GITHUB_ENV | |
echo "DB_USERNAME=${{ secrets.DB_USERNAME }}" >> $GITHUB_ENV | |
echo "DB_PASSWORD=${{ secrets.DB_PASSWORD }}" >> $GITHUB_ENV | |
- name: Check environment variables | |
run: | | |
echo "REDIS_HOST=${REDIS_HOST}" | |
echo "REDIS_PORT=${REDIS_PORT}" | |
echo "DB_URL=${DB_URL}" | |
echo "DB_USERNAME=${DB_USERNAME}" | |
echo "DB_PASSWORD=${DB_PASSWORD}" | |
- name: Setup Gradle | |
uses: gradle/actions/setup-gradle@v3 | |
- name: Create src/main/resources directory | |
run: | | |
mkdir -p src/main/resources | |
mkdir -p src/main/resources/yml | |
- name: Create application.yml | |
run: | | |
echo "${{ secrets.APPLICATION_YML }}" > src/main/resources/application.yml | |
echo "${{ secrets.APPLICATION_PROD_YML }}" > src/main/resources/yml/application-prod.yml | |
- name: Build with Gradle Wrapper | |
run: ./gradlew build | |
- name: Make zip file | |
run: zip -r ./$GITHUB_SHA.zip . | |
shell: bash | |
- name: Configure AWS credentials | |
uses: aws-actions/configure-aws-credentials@v1 | |
with: | |
role-to-assume: ${{ secrets.AWS_ARN }} | |
aws-region: ${{ secrets.AWS_DEFAULT_REGION }} | |
- name: Upload to S3 | |
run: aws s3 cp --region ap-northeast-2 ./$GITHUB_SHA.zip s3://${{ secrets.AWS_S3_BUCKET }}/cicd/$GITHUB_SHA.zip | |
- name: Create CodeDeploy deployment | |
run: aws deploy create-deployment | |
--application-name ${{ secrets.AWS_CODE_DEPLOY_APPLICATION }} | |
--deployment-config-name CodeDeployDefault.AllAtOnce | |
--deployment-group-name ${{ secrets.AWS_CODE_DEPLOY_GROUP }} | |
--s3-location bucket=${{ secrets.AWS_S3_BUCKET }},key=cicd/$GITHUB_SHA.zip,bundleType=zip | |
--debug |