Skip to content

수정

수정 #4

name: farmmate-server
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
workflow_dispatch:
jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '18'
cache: 'npm'
- name: Install Dependencies
run: npm install
- name: Install ts-patch
run: npm install ts-patch --save-dev
- name: Apply ts-patch
run: npx ts-patch install
- name: Install and apply typia
run: |
npm install typia
npx typia patch
- name: Build project
run: npm run build
- 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: ${{ secrets.AWS_REGION }}
- name: Zip the project
run: zip -r project.zip .
- name: Upload to S3
run: aws s3 cp project.zip s3://${{ secrets.S3_BUCKET_NAME }}/${{ github.run_id }}.zip
- name: Deploy to EC2 using CodeDeploy
run: |
aws deploy create-deployment --application-name ${{ secrets.CODEDEPLOY_APP_NAME }} \
--s3-location bucket=${{ secrets.S3_BUCKET_NAME }},bundleType=zip,key=${{ github.run_id }}.zip \
--deployment-group-name ${{ secrets.DEPLOYMENT_GROUP_NAME }} \
--deployment-config-name CodeDeployDefault.AllAtOnce
- name: Set up environment variables
run: |
echo "DB_TYPE=${{ secrets.DB_TYPE }}" >> $GITHUB_ENV
echo "DB_HOST=${{ secrets.DB_HOST }}" >> $GITHUB_ENV
echo "DB_PORT=${{ secrets.DB_PORT }}" >> $GITHUB_ENV
echo "DB_USERNAME=${{ secrets.DB_USERNAME }}" >> $GITHUB_ENV
echo "DB_PASSWORD=${{ secrets.DB_PASSWORD }}" >> $GITHUB_ENV
echo "DB_DATABASE=${{ secrets.DB_DATABASE }}" >> $GITHUB_ENV