-
Notifications
You must be signed in to change notification settings - Fork 7
87 lines (73 loc) · 2.33 KB
/
python-app.yml
File metadata and controls
87 lines (73 loc) · 2.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
name: Hackernews API
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
build:
runs-on: ubuntu-latest
services:
postgres:
image: postgres:11
env:
POSTGRES_DB: hn_test
POSTGRES_PASSWORD: hn123
POSTGRES_USER: postgres
ports:
- 5432:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
steps:
- uses: actions/checkout@v2
- name: Setup Python
uses: actions/setup-python@v2
with:
python-version: 3.8
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install -r requirements-dev.txt
- name: Python Linter
run: pylint hackernews/**/*.py
- name: Rodar migrations
run: flask db upgrade
env:
FLASK_APP: hackernews.app
FLASK_ENV: development
DATABASE_URI: postgresql://postgres:hn123@localhost:5432/hn_test
- name: Tests
run: pytest --cache-clear
env:
FLASK_APP: hackernews.app
FLASK_ENV: development
DATABASE_URI: postgresql://postgres:hn123@localhost:5432/hn_test
- name: Set up Docker Builder
uses: docker/setup-buildx-action@v1
- name: Log into GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.CR_PAT }}
- name: Extract branch name
shell: bash
run: echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/})"
id: extract_branch
- name: Extract commit sha
shell: bash
run: echo "##[set-output name=github_sha;]$(echo ${GITHUB_REF#refs/heads/}.${GITHUB_SHA})"
id: extract_sha
# Push to Github Container Registry
- name: Push to Github Container Registry
uses: docker/build-push-action@v2
with:
context: .
version: ${{ steps.extract_branch.outputs.branch }}
file: Dockerfile
target: production
push: true
build-args: GIT_HASH=${{ steps.extract_sha.outputs.github_sha }}
tags: "ghcr.io/${{ github.repository }}:${{ steps.extract_branch.outputs.branch }}"