Skip to content

Instantly share code, notes, and snippets.

@thixpin
Created March 25, 2024 14:32
Show Gist options
  • Save thixpin/22da27813bcd2576534bf088f349c6e7 to your computer and use it in GitHub Desktop.
Save thixpin/22da27813bcd2576534bf088f349c6e7 to your computer and use it in GitHub Desktop.
wd-s3-cicd-lab
image: alpine:latest
stages:
- build
- test
- deploy
# variables:
# S3_BUCKET: "my-bucket"
# AWS_REGION: "up-southeast-1"
before_script:
- echo "Setting up the environment..."
# - apk add --no-cache bash
- echo "Environment setup completed successfully."
build:
stage: build
script:
- echo "Building the application..."
# - npm install
# - npm run build
# artifacts:
# paths:
# - node_modules/
# - dist/
# expire_in: 1 week
when: manual
only:
- master
- main
- develop
deploy-dev:
stage: deploy
only:
- develop
needs:
- build
# - test
when: on_success
script:
- echo "Installing AWS CLI..."
- apk add --no-cache aws-cli
- echo "Uploading to S3..."
- aws s3 sync ./ s3://$S3_BUCKET_DEV --delete --exclude ".git/*"
# - echo "Invalidating CloudFront cache..."
# - aws cloudfront create-invalidation --distribution-id $CLOUDFRONT_DISTRIBUTION_ID_DEV --paths "/*"
- echo "Deployment to DEV environment completed successfully."
deploy-prod:
stage: deploy
only:
- master
- main
needs:
- build
# - test
when: on_success
script:
- echo "Installing AWS CLI..."
- apk add --no-cache aws-cli
- echo "Uploading to S3..."
- aws s3 sync ./ s3://$S3_BUCKET_PROD --delete --exclude ".git/*"
# - echo "Invalidating CloudFront cache..."
# - aws cloudfront create-invalidation --distribution-id $CLOUDFRONT_DISTRIBUTION_ID_PROD --paths "/*"
- echo "Deployment to PROD environment completed successfully."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment