Created
April 29, 2020 14:16
-
-
Save ankitdbst/bc40c9dcc4282f18794963ab88310b82 to your computer and use it in GitHub Desktop.
Gitlab CI to deploy magento2 on AWS
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: ruby:2.5 | |
stages: | |
- deploy | |
default: | |
before_script: | |
# For setting the IP of the runner with Amazon EC2 SG | |
- apt update | |
- apt install -y awscli jq | |
- 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 | |
- chmod +x update-ip.sh | |
- ./update-ip.sh $AWS_EC2_SG_NAME gitlab-ci | |
# For magento deployment | |
- gem install capistrano-magento2 | |
# Start ssh agent | |
- which ssh-agent || ( apt-get update -y && apt-get install openssh-client -y ) | |
- eval $(ssh-agent -s) | |
# add gitlab ssh key stored in SSH_PRIVATE_KEY variable to the agent store | |
- ssh-add <(echo -e "$SSH_PRIVATE_KEY") | |
staging_deploy: | |
stage: deploy | |
script: | |
- ssh-add <(echo -e "$DEV_SSH_PRIVATE_KEY") | |
- cd tools/cap | |
- cap staging deploy | |
only: | |
- develop | |
production_deploy: | |
stage: deploy | |
script: | |
- ssh-add <(echo -e "$PROD_SSH_PRIVATE_KEY") | |
- cd tools/cap | |
- cap production deploy | |
only: | |
- master |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment