Skip to content

Workflow file for this run

name: Lint and build Docker
on: [push, pull_request]
jobs:
lint:
timeout-minutes: 10
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v1
- name: Setup Python
uses: actions/setup-python@v2
with:
python-version: "3.7"
- name: Install Dependencies
run: |
python -m pip install --upgrade pip
cd source-code/chapter-7/exercise-2/newsbot-compose
pip install -r requirements.txt
- name: Lint with flake8
run: |
pip install flake8
cd source-code/chapter-7/exercise-2/newsbot-compose
# run flake8 first to detect any python syntax errors
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# run again to exit treating all errors as warnings
flake8 . --count --exit-zero --max-complexity=10 --statistics
docker-build:
timeout-minutes: 10
runs-on: ubuntu-latest
needs: lint
steps:
- name: Checkout
uses: actions/checkout@v1
- name: Build Docker Image
env:
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
run: |
cd source-code/chapter-7/exercise-2/newsbot-compose
docker login -u ${DOCKER_USERNAME} -p ${DOCKER_PASSWORD}
docker build -t ${DOCKER_USERNAME}/newsbot:${GITHUB_SHA} .
docker push ${DOCKER_USERNAME}/newsbot:${GITHUB_SHA}