diff --git a/.github/workflows/deploy-dev-backend.yml b/.github/workflows/deploy-dev-backend.yml index 7f8afadf5..72964fab2 100644 --- a/.github/workflows/deploy-dev-backend.yml +++ b/.github/workflows/deploy-dev-backend.yml @@ -1,8 +1,10 @@ name: DeployDevBackend on: push: + tags: + - '*' branches: - - master + - '*' jobs: deploy-backend: @@ -18,8 +20,6 @@ jobs: with: go-version: '^1.17.5' - - uses: actions/setup-node@v1 - - name: Configure AWS credentials uses: aws-actions/configure-aws-credentials@v1 with: @@ -50,6 +50,7 @@ jobs: parameter-overrides: >- EnvName=dev, S3BucketName=dev-stack-canopas-backend, + CustomDomainName=dev-stack-api.canopas.com, LambdaHandlerPath=main, LambdaZipFilePath=${{ env.ZIP_NAME }}, Sender=${{ secrets.SENDER }}, diff --git a/.github/workflows/deploy-dev-frontend.yml b/.github/workflows/deploy-dev-frontend.yml index bb31f63d4..762d617ed 100644 --- a/.github/workflows/deploy-dev-frontend.yml +++ b/.github/workflows/deploy-dev-frontend.yml @@ -1,8 +1,10 @@ name: DeployDevFrontend on: push: + tags: + - '*' branches: - - master + - '*' jobs: deploy-frontend: @@ -23,6 +25,7 @@ jobs: with: role-to-assume: arn:aws:iam::569704406482:role/github-actions-s3-access aws-region: ap-south-1 + - name: Deploy cloudfront id: canopas-website-dev-frontend-stack uses: aws-actions/aws-cloudformation-github-deploy@v1 @@ -33,12 +36,15 @@ jobs: timeout-in-minutes: "10" no-fail-on-empty-changeset: "1" parameter-overrides: >- - S3BucketName=dev-stack-canopas-v1-frontend + S3BucketName=dev-stack-canopas-v1-frontend, + CustomDomainName=dev-stack.canopas.com + - name: Build frontend run: | cd vue-frontend npm ci npm run build + - name: Upload to S3 run: | cd vue-frontend diff --git a/.github/workflows/deploy-prod-backend.yml b/.github/workflows/deploy-prod-backend.yml new file mode 100644 index 000000000..30dea8bfa --- /dev/null +++ b/.github/workflows/deploy-prod-backend.yml @@ -0,0 +1,62 @@ +name: DeployProdBackend +on: + push: + tags: + - '*' + branches: + - '*' + +jobs: + deploy-backend: + runs-on: ubuntu-latest + permissions: + id-token: write + contents: read + steps: + - name: Checkout + uses: actions/checkout@v2.3.3 + + - uses: actions/setup-go@v2 + with: + go-version: '^1.17.5' + + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@v1 + with: + role-to-assume: arn:aws:iam::569704406482:role/github-actions-s3-access + aws-region: ap-south-1 + - name: Build backend + run: | + GOOS=linux GOARCH=amd64 go build -o main main.go + - name: Zip function + run: | + apt-get update && apt-get install -y zip + uuid=$(uuidgen) + export ZIP_NAME="canopas-website-v1-${uuid}.zip" + zip $ZIP_NAME main + echo "ZIP_NAME=$ZIP_NAME" >> $GITHUB_ENV + - name: Upload to S3 + run: | + aws s3 cp ${{ env.ZIP_NAME }} s3://prod-stack-canopas-backend/ + - name: Deploy lambda function + id: canopas-website-prod-backend-stack + uses: aws-actions/aws-cloudformation-github-deploy@v1 + with: + name: canopas-website-prod-backend-stack + template: infrastructure/template-backend.yml + capabilities: CAPABILITY_IAM,CAPABILITY_NAMED_IAM + timeout-in-minutes: "5" + no-fail-on-empty-changeset: "1" + parameter-overrides: >- + EnvName=prod, + S3BucketName=prod-stack-canopas-backend, + CustomDomainName=prod-stack-api.canopas.com, + LambdaHandlerPath=main, + LambdaZipFilePath=${{ env.ZIP_NAME }}, + Sender=${{ secrets.SENDER }}, + Receiver=${{ secrets.RECEIVER }}, + AccessKeyId=${{ secrets.ACCESS_KEY_ID }}, + SecretAccessKey=${{ secrets.SECRET_ACCESS_KEY }}, + Region=${{ secrets.AWS_REGION }} + + \ No newline at end of file diff --git a/.github/workflows/deploy-prod-frontend.yml b/.github/workflows/deploy-prod-frontend.yml new file mode 100644 index 000000000..678da6da6 --- /dev/null +++ b/.github/workflows/deploy-prod-frontend.yml @@ -0,0 +1,53 @@ +name: DeployProdFrontend +on: + push: + tags: + - '*' + branches: + - '*' + +jobs: + deploy-frontend: + runs-on: ubuntu-latest + permissions: + id-token: write + contents: read + steps: + - name: Checkout + uses: actions/checkout@v2.3.3 + + - uses: actions/setup-node@v1 + with: + node-version: '16' + + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@v1 + with: + role-to-assume: arn:aws:iam::569704406482:role/github-actions-s3-access + aws-region: ap-south-1 + + - name: Deploy cloudfront + id: canopas-website-prod-frontend-stack + uses: aws-actions/aws-cloudformation-github-deploy@v1 + with: + name: canopas-website-prod-frontend-stack + template: infrastructure/template-frontend.yml + capabilities: CAPABILITY_IAM,CAPABILITY_NAMED_IAM + timeout-in-minutes: "10" + no-fail-on-empty-changeset: "1" + parameter-overrides: >- + S3BucketName=prod-stack-canopas-v1-frontend, + CustomDomainName=canopas.com + + - name: Build frontend + run: | + cd vue-frontend + npm ci + mv src/config.prod.js src/config.js + npm run build + + - name: Upload to S3 + run: | + cd vue-frontend + aws s3 sync --delete --cache-control 'max-age=31536000' --exclude *.html dist/ s3://prod-stack-canopas-v1-frontend/ + aws s3 sync --cache-control 'no-cache' dist/ s3://prod-stack-canopas-v1-frontend/ \ No newline at end of file diff --git a/infrastructure/template-backend.yml b/infrastructure/template-backend.yml index f55bc3ba7..428316ba9 100644 --- a/infrastructure/template-backend.yml +++ b/infrastructure/template-backend.yml @@ -12,6 +12,9 @@ Parameters: Description: Name of the S3 bucket AllowedPattern: ^.*[^0-9]$ ConstraintDescription: Must end with non-numeric character. + CustomDomainName: + Type: String + Description: Name of the custom domain Sender: Type: String Description: Email address of sender. @@ -51,7 +54,7 @@ Outputs: - Arn Export: Name: - Fn::Sub: LambdaRole + Fn::Sub: LambdaRole-${EnvName} LambdaFunctionName: Value: Ref: LambdaFunction @@ -194,7 +197,7 @@ Resources: DependsOn: - ApiGatewayDeployment Properties: - DomainName: dev-go-vue.canopas.com + DomainName: !Ref CustomDomainName RestApiId: !Ref ApiGateway Stage: !Ref ApiGatewayStageName diff --git a/infrastructure/template-frontend.yml b/infrastructure/template-frontend.yml index 50f92a5df..57f1d9e14 100644 --- a/infrastructure/template-frontend.yml +++ b/infrastructure/template-frontend.yml @@ -7,6 +7,9 @@ Parameters: Description: Name of the S3 bucket AllowedPattern: ^.*[^0-9]$ ConstraintDescription: Must end with non-numeric character. + CustomDomainName: + Type: String + Description: Name of the custom domain Outputs: CloudFrontDist: @@ -49,14 +52,14 @@ Resources: DefaultRootObject: index.html HttpVersion: http2 Aliases: - - dev-stack.canopas.com + - !Ref CustomDomainName CustomErrorResponses: - ErrorCachingMinTTL: 31536000 ErrorCode: 403 ResponseCode: 200 ResponsePagePath: '/index.html' ViewerCertificate: - AcmCertificateArn: 'arn:aws:acm:us-east-1:569704406482:certificate/61f88a8a-9346-4e90-9d62-d0b20cd71765' + AcmCertificateArn: 'arn:aws:acm:us-east-1:569704406482:certificate/4e2d0bf9-3e0d-4581-9292-a0ba91179f00' MinimumProtocolVersion: TLSv1.2_2021 SslSupportMethod: sni-only DefaultCacheBehavior: diff --git a/vue-frontend/public/index.html b/vue-frontend/public/index.html index 9d343e59a..2418ba13b 100644 --- a/vue-frontend/public/index.html +++ b/vue-frontend/public/index.html @@ -5,10 +5,37 @@ - - Canopas - Creative solutions using innovative design, technology, and - strategy. - + + + + + + + + + Canopas - Software development company - Surat + + + +