Merge pull request #330 from Team-TenTen/develop #39
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 | |
on: | |
push: | |
branches: | |
- main | |
env: | |
S3_BUCKET_NAME: linkhub.site | |
CODE_DEPLOY_APPLICATION_NAME: team10-fe-code-deploy | |
CODE_DEPLOY_DEPLOYMENT_GROUP_NAME: team-10-fe | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Setup Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 18.x | |
- name: Generate Environment Variables File | |
run: | | |
echo "NEXT_PUBLIC_API_ADDRESS=$NEXT_PUBLIC_API_ADDRESS" >> .env | |
echo "NEXT_PUBLIC_API_INTERNAL_ADDRESS=$NEXT_PUBLIC_API_INTERNAL_ADDRESS" >> .env | |
env: | |
NEXT_PUBLIC_API_ADDRESS: ${{ secrets.NEXT_PUBLIC_API_ADDRESS }} | |
NEXT_PUBLIC_API_INTERNAL_ADDRESS: ${{ secrets.NEXT_PUBLIC_API_INTERNAL_ADDRESS }} | |
- name: Install dependencies | |
run: npm install | |
- name: Build next app | |
run: npm run build | |
- name: Make zip file | |
run: zip -qq -r ./$GITHUB_SHA.zip . -x "node_modules/*" | |
shell: bash | |
- name: Configure AWS credentials | |
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: ap-northeast-2 | |
- name: Upload to S3 | |
run: aws s3 cp --region ap-northeast-2 ./$GITHUB_SHA.zip s3://$S3_BUCKET_NAME/$GITHUB_SHA.zip | |
- name: Code Deploy | |
run: aws deploy create-deployment | |
--deployment-config-name CodeDeployDefault.AllAtOnce | |
--application-name ${{ env.CODE_DEPLOY_APPLICATION_NAME }} | |
--deployment-group-name ${{ env.CODE_DEPLOY_DEPLOYMENT_GROUP_NAME }} | |
--s3-location bucket=$S3_BUCKET_NAME,bundleType=zip,key=$GITHUB_SHA.zip |