Skip to content

Instantly share code, notes, and snippets.

@urbsny
Last active April 18, 2020 06:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save urbsny/ddb634e5f677e1d4d312f4a86916adc8 to your computer and use it in GitHub Desktop.
Save urbsny/ddb634e5f677e1d4d312f4a86916adc8 to your computer and use it in GitHub Desktop.
Compare with GItLab CI and Github Actions
name: CI
on:
push:
branches:
- '*'
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'
jobs:
test:
runs-on: ubuntu-latest
services:
database:
image: postgres:12.2
env:
POSTGRES_PASSWORD: xxxxxxxx
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
cache:
image: redis:5.0.8
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 6379:6379
env:
DATABASE_URL: postgres://postgres:xxxxxxxx@localhost:5432/postgres
REDIS_URL: redis://localhost:6379
SAMPLE_VARIABLE: 1
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v1
with:
python-version: 3.8.2
- run: python -m pip install --upgrade pip
- run: pip install pipenv
- run: pipenv install -d
- run: pipenv run collectstatic
- run: pipenv run testcoverage
- run: pipenv run coveragehtml
- uses: actions/upload-artifact@v1
with:
name: coverage
path: htmlcov/
deploy-staging:
needs: test
if: github.ref == 'refs/heads/master'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: sudo apt-get update -qy
- run: sudo apt-get install -y ruby-dev
- run: sudo gem install dpl
- run: sudo dpl --provider=heroku --app=$HEROKU_APP --api-key=$HEROKU_API_KEY
env:
HEROKU_APP: ${{ secrets.HEROKU_APP }}
HEROKU_API_KEY: ${{ secrets.HEROKU_API_KEY }}
deploy-production:
needs: test
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: echo TODO
cache:
untracked: true
test:
image: python:3.8.2
services:
- name: postgres:12.2
alias: database
- name: redis:5.0.8
alias: cache
variables:
POSTGRES_PASSWORD: xxxxxxxx
DATABASE_URL: postgres://postgres:xxxxxxxx@database:5432/postgres
REDIS_URL: redis://cache:6379
SAMPLE_VARIABLE: 1
script:
- python -m pip install --upgrade pip
- pip install pipenv
- pipenv install -d
- pipenv run collectstatic
- pipenv run testcoverage
- pipenv run coveragehtml
artifacts:
paths:
- htmlcov/
deploy-staging:
stage: deploy
script:
- apt-get update -qy
- apt-get install -y ruby-dev
- gem install dpl
- dpl --provider=heroku --app=$HEROKU_APP --api-key=$HEROKU_API_KEY
only:
- master
deploy-production:
stage: deploy
script:
- echo TODO
only:
- tags
- /^v[0-9]+\.[0-9]+\.[0-9]+$/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment