Skip to content

Commit

Permalink
👷 Add GitHub actions for CI (#37)
Browse files Browse the repository at this point in the history
* 👷 Try to add GitHub action for CI

* 🔧 Add env vars to GitHub action

* ♻️ Deduplicate and simplify build

* 🐳 Add Docker deploy to GitHub action

* 🔒 Add Docker auth for deploy

* 👷 Disable Travis, keep backup
  • Loading branch information
tiangolo authored Apr 27, 2020
1 parent 738fd7e commit 24dd544
Show file tree
Hide file tree
Showing 9 changed files with 111 additions and 10 deletions.
44 changes: 44 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Deploy Docker Images

on:
push:
branches:
- master

jobs:
build:
strategy:
matrix:
image:
- name: latest
python_version: "3.8"
- name: python3.8
python_version: "3.8"
- name: python3.7
python_version: "3.7"
- name: python3.6
python_version: "3.6"
- name: python3.8-alpine3.10
python_version: "3.8"
- name: python3.7-alpine3.8
python_version: "3.7"
- name: python3.6-alpine3.8
python_version: "3.6"
fail-fast: true
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v1
with:
python-version: "3.7"
- name: Install Dependencies
run: python3.7 -m pip install docker pytest
- name: Deploy Image
run: bash scripts/build-push.sh
env:
NAME: ${{ matrix.image.name }}
DOCKERFILE: ${{ matrix.image.dockerfile }}
PYTHON_VERSION: ${{ matrix.image.python_version }}
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
name: Issue Manager

on:
schedule:
- cron: "0 0 * * *"
Expand Down
42 changes: 42 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Test Docker Images

on:
push:
pull_request:
types: [opened, synchronize]

jobs:
build:
strategy:
matrix:
image:
- name: latest
python_version: "3.8"
- name: python3.8
python_version: "3.8"
- name: python3.7
python_version: "3.7"
- name: python3.6
python_version: "3.6"
- name: python3.8-alpine3.10
python_version: "3.8"
- name: python3.7-alpine3.8
python_version: "3.7"
- name: python3.6-alpine3.8
python_version: "3.6"
fail-fast: true
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v1
with:
python-version: "3.7"
- name: Install Dependencies
run: python3.7 -m pip install docker pytest
- name: Test Image
run: bash scripts/test.sh
env:
NAME: ${{ matrix.image.name }}
DOCKERFILE: ${{ matrix.image.dockerfile }}
PYTHON_VERSION: ${{ matrix.image.python_version }}
2 changes: 1 addition & 1 deletion .travis.yml → backup.travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ services:
- docker

env:
- NAME='latest' DOCKERFILE='python3.8' PYTHON_VERSION='3.8'
- NAME='latest' PYTHON_VERSION='3.8'
- NAME='python3.8' PYTHON_VERSION='3.8'
- NAME='python3.7' PYTHON_VERSION='3.7'
- NAME='python3.6' PYTHON_VERSION='3.6'
Expand Down
2 changes: 1 addition & 1 deletion scripts/build-push-all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

set -e

echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
bash scripts/docker-login.sh

BUILD_PUSH=1 python scripts/process_all.py
6 changes: 3 additions & 3 deletions scripts/build-push.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ set -e
use_tag="tiangolo/uvicorn-gunicorn:$NAME"
use_dated_tag="${use_tag}-$(date -I)"

DOCKERFILE=${DOCKERFILE-$NAME}

docker build -t "$use_tag" --file "./docker-images/${DOCKERFILE}.dockerfile" "./docker-images/"
bash scripts/build.sh

docker tag "$use_tag" "$use_dated_tag"

bash scripts/docker-login.sh

docker push "$use_tag"
docker push "$use_dated_tag"
12 changes: 12 additions & 0 deletions scripts/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/env bash
set -e

use_tag="tiangolo/uvicorn-gunicorn:$NAME"

DOCKERFILE="$NAME"

if [ "$NAME" == "latest" ] ; then
DOCKERFILE="python3.8"
fi

docker build -t "$use_tag" --file "./docker-images/${DOCKERFILE}.dockerfile" "./docker-images/"
5 changes: 5 additions & 0 deletions scripts/docker-login.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env bash

set -e

echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
6 changes: 1 addition & 5 deletions scripts/test.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
#!/usr/bin/env bash
set -e

use_tag="tiangolo/uvicorn-gunicorn:$NAME"

DOCKERFILE=${DOCKERFILE-$NAME}

docker build -t "$use_tag" --file "./docker-images/${DOCKERFILE}.dockerfile" "./docker-images/"
bash scripts/build.sh
pytest tests

0 comments on commit 24dd544

Please sign in to comment.