Skip to content

Merge pull request #185 from WCpedia/develop #45

Merge pull request #185 from WCpedia/develop

Merge pull request #185 from WCpedia/develop #45

Workflow file for this run

name: RELEASE-CICD
on:
push:
branches: [release]
jobs:
Build_and_Test:
name: Build and Test
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v3
- name: Setup node.js
uses: actions/[email protected]
with:
node-version: 18.18.2
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v2
with:
aws-access-key-id: ${{ secrets.RELEASE_S3_ACCESS_KEY }}
aws-secret-access-key: ${{ secrets.RELEASE_S3_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.S3_REGION }}
- name: Download Test Environment file from S3 and Check
run: aws s3 cp ${{ secrets.S3_TEST_ENV }} .env
- name: Install Dependencies
run: npm ci
- name: Compile Backend-Server
run: npm run build
- name: Unit Test
run: npm run test:unit
- name: Make a zip file
run: zip -r ./build.zip . -x "node_modules/*" "coverage/*" "src/*" "test/*" "README.md" "*.git*" "common/*" "tsconfig.json" "tsconfig.build.json" "nest-cli.json" "*.env"
shell: bash
- name: Upload build to artifact
uses: actions/upload-artifact@v3
with:
name: build-artifact
path: ./build.zip
Deploy:
name: Deploy
runs-on: ubuntu-latest
needs: Build_and_Test
steps:
- name: Download build artifact
uses: actions/download-artifact@v3
with:
name: build-artifact
path: .
- name: Dynamically set MY_DATE environment variable
run: echo "MY_DATE=$(date +%Y%m%d-%H%M)" >> $GITHUB_ENV
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v2
with:
aws-access-key-id: ${{ secrets.RELEASE_S3_ACCESS_KEY }}
aws-secret-access-key: ${{ secrets.RELEASE_S3_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.S3_REGION }}
- name: Upload to S3
run: aws s3 cp --region ${{ secrets.S3_REGION }} ./build.zip s3://${{secrets.RELEASE_S3_BUCKET_NAME}}/${{secrets.RELEASE_S3_FOLDER_NAME}}/${{ env.MY_DATE }}.zip
- name: Code Deploy
run: aws deploy create-deployment
--application-name ${{secrets.RELEASE_S3_CODEDEPLOY_APPLICATION_NAME}}
--deployment-config-name CodeDeployDefault.AllAtOnce
--deployment-group-name ${{secrets.RELEASE_S3_CODEDEPLOY_DEPLOYMENT_GROUP_NAME}}
--s3-location bucket=${{secrets.RELEASE_S3_BUCKET_NAME}},bundleType=zip,key=${{secrets.RELEASE_S3_FOLDER_NAME}}/${{ env.MY_DATE }}.zip