Created
March 25, 2024 14:32
-
-
Save thixpin/22da27813bcd2576534bf088f349c6e7 to your computer and use it in GitHub Desktop.
wd-s3-cicd-lab
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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