I have a project written in Django (Python Framework) and repository in Bitbucket
I have to setup a bitbucket pipeline with the following actions:
- Deploy in Staging server and commits are made to staging branch
- Deploy to Production server when a release is a draft from the master branch only.
I'm not sure where release can be draft in Bitbucket like Github.
I have the following bitbucket-pipelines.yml file
image: python:3.7
pipelines:
branches:
staging:
- step:
deployment: staging
script:
- apt-get update
- apt-get install -y zip # required for packaging up the application
- pip install boto3==1.3.0 # required for codedeploy_deploy.py
- zip -r /tmp/artifact.zip * # package up the application for deployment
- python codedeploy_deploy.py # run the deployment script
Now, In the Django application, I'm using .env
to serve credentials and settings. For a different environment, say development, staging, and production, I have different environment files for each
development.env
staging.env
production.env
I need to rename/copy the respective file to .env
depending on the deployment type.
How can I set up this in bitbucket pipeline to carry out this step?
appspec.yml contents are:
version: 0.0
os: linux
files:
- source: /
destination: /var/www/html/project/
permissions:
- object: /var/www/html
pattern: "**"
owner: ubuntu
group: ubuntu
hooks:
BeforeInstall:
- location: scripts/clean_instance.sh
timeout: 6000
runas: root
AfterInstall:
- location: scripts/install_os_dependencies.sh
timeout: 6000
runas: root
- location: scripts/install_python_dependencies.sh
timeout: 6000
runas: ubuntu
- location: scripts/setup_environment.sh
timeout: 6000
runas: ubuntu
- location: scripts/migrate.sh
timeout: 6000
runas: ubuntu
- location: scripts/ngnix.sh
timeout: 6000
runas: ubuntu
ApplicationStart:
- location: scripts/start_application.sh
timeout: 6000
runas: ubuntu
ApplicationStop:
- location: scripts/stop_application.sh
timeout: 6000
runas: ubuntu
Can I have multiple appspec.yml files depending on the deployment type?