Last active
June 13, 2025 15:42
-
-
Save DennisAlund/d20ebc8c6f700b1aa3d370d94548d3e2 to your computer and use it in GitHub Desktop.
Gitlab CI configuration for the Medium article "Deploying Django to Google App Engine with Gitlab CI" -- https://medium.com/evenbit/deploying-django-to-google-app-engine-with-gitlab-ci-541c0dc67a12
This file contains hidden or 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: python:2.7 | |
| .deploy_template: &global_deploy_def | |
| stage: deploy | |
| before_script: | |
| - echo "deb http://packages.cloud.google.com/apt cloud-sdk-jessie main" | tee /etc/apt/sources.list.d/google-cloud-sdk.list | |
| - curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add - | |
| - apt-get update && apt-get install google-cloud-sdk | |
| after_script: | |
| - source .gitlab-ci.env | |
| - sed --in-place -e "s/envconf\.\w*/envconf\.$CONFIGURATION_ENVIRONMENT/g" akses/settings.py | |
| - sed --in-place -e "s/SECRET_KEY\s*=\s*'.*'/SECRET_KEY = '$DJANGO_SECRET_KEY'/g" akses/settings.py | |
| - pip install -r requirements-vendor.txt -t lib/ | |
| - pip install -r requirements-local.txt | |
| - python manage.py migrate | |
| - python manage.py collectstatic --noinput --pythonpath lib | |
| - gcloud auth activate-service-account --key-file .gitlab-ci.keyfile.json | |
| - gcloud --quiet --project $PROJECT_ID app deploy | |
| deploy_production: | |
| <<: *global_deploy_def | |
| environment: Production | |
| only: | |
| - master | |
| script: | |
| - touch .gitlab-ci.env | |
| - echo "export PROJECT_ID=$PROJECT_ID_PRODUCTION" >> .gitlab-ci.env | |
| - echo "export CONFIGURATION_ENVIRONMENT=production" >> .gitlab-ci.env | |
| - echo "export DJANGO_SECRET_KEY='$DJANGO_SECRET_KEY_PRODUCTION'" >> .gitlab-ci.env | |
| - echo $DEPLOY_KEY_FILE_PRODUCTION > .gitlab-ci.keyfile.json |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment