Skip to content

Instantly share code, notes, and snippets.

@Sikandarkhan
Last active February 19, 2022 06:27
Show Gist options
  • Save Sikandarkhan/9070c4fe9a1debb59b1af88cbbc136a6 to your computer and use it in GitHub Desktop.
Save Sikandarkhan/9070c4fe9a1debb59b1af88cbbc136a6 to your computer and use it in GitHub Desktop.
CI CD for angular application
stages:
- build
- deploy
# Job One for making build
build:
image: node:14.15
stage: build
script:
- npm i @angular/compiler-cli@13.2
- npm install
- npm run build --prod
# only: ['master']
artifacts:
paths:
- public/
expire_in: 1 hour
only:
- master
# Job Two for deploy build to S3
deploy:
image: python:latest
stage: deploy
only:
- master
# before_script:
script:
- pip install awscli
- aws configure set aws_access_key_id $AWS_ACCESS_KEY_ID
- aws configure set aws_secret_access_key $AWS_SECRET_ACCESS_KEY
- aws configure set region $AWS_DEFAULT_REGION
- aws s3 rm s3://$AWS_BUCKET_NAME --recursive
- aws s3 sync ./public s3://$AWS_BUCKET_NAME --acl=public-read --delete
- aws cloudfront create-invalidation --distribution-id E1B3ZGAWWAS4L0 --paths "/*"
# - aws s3 sync ./dist s3://AWS_BUCKET_NAME --acl=public-read --delete
# only: ['master']
# Node Image for docker on which code will execute
# image: node:latest
# This is the stages / task to perfom in jobs
# variables:
# S3_BUCKET_NAME: "myBucketName"
# AWS_DEFAULT_REGION: "eu-west-1" # make sure this is YOUR region
# AWS_ACCESS_KEY_ID: "BIG_KEY"
# AWS_SECRET_ACCESS_KEY: "BIG_SECRET" # you can use gitlab variables if you want to hide these
# stages:
# - install
# - build
# - deploy
# # install all you need
# install:
# stage: install
# image: node:12.18.1
# script:
# - apt-get --quiet update --yes
# - apt-get --quiet install --yes wget tar unzip lib32stdc++6 lib32z1
# - apt-get --quiet install -y build-essential
# - curl -sL http://deb.nodesource.com/setup_12.x | bash -
# - apt-get --quiet install -y nodejs
# - apt-get --quiet update --yes
# - npm -v
# - npm install -g @angular/cli
# # build production
# build:
# stage: build
# image: node:12.18.1
# script:
# - npm install -g @angular/cli
# - npm install
# - npm run build:prod
# artifacts:
# paths:
# - dist/
# # deploy to s3
# deploy:
# stage: deploy
# image: python:latest
# script:
# - pip install awscli
# - aws s3 sync ./dist s3://$S3_BUCKET_NAME/ --delete
# only:
# - master
# build-job:
# stage: build
# script:
# - echo "Hello, $GITLAB_USER_LOGIN!"
# test-job1:
# stage: test
# script:
# - echo "This job tests something"
# test-job2:
# stage: test
# script:
# - echo "This job tests something, but takes more time than test-job1."
# - echo "After the echo commands complete, it runs the sleep command for 20 seconds"
# - echo "which simulates a test that runs 20 seconds longer than test-job1"
# - sleep 20
# deploy-prod:
# stage: deploy
# script:
# - echo "This job deploys something from the $CI_COMMIT_BRANCH branch."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment