-
Notifications
You must be signed in to change notification settings - Fork 0
117 lines (100 loc) · 2.98 KB
/
ci.yml
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
name: "CI: AUTH"
# Enable Buildkit and let compose use it to speed up image building
env:
DOCKER_BUILDKIT: 1
COMPOSE_DOCKER_CLI_BUILD: 1
on:
pull_request:
branches: ["master", "main"]
paths-ignore: ["docs/**"]
push:
branches: ["master", "main"]
paths-ignore: ["docs/**"]
workflow_dispatch:
concurrency:
group: "build"
cancel-in-progress: true
jobs:
linter:
runs-on: ubuntu-latest
steps:
- name: Checkout Code Repository
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.11"
cache: pip
cache-dependency-path: |
requirements/base.txt
requirements/local.txt
- name: pre-commit
run: |
python3.11 -m venv .venv
source .venv/bin/activate
pip install -r requirements/local.txt
pip install -r requirements/production.txt
pre-commit run --show-diff-on-failure --color=always --all-files
pytest:
runs-on: ubuntu-latest
needs:
- linter
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Login to GHCR
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.TOKEN }}
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.11"
cache: pip
cache-dependency-path: |
requirements/base.txt
requirements/local.txt
- name: pytest
run: |
python3.11 -m venv .venv
source .venv/bin/activate
pip install -r requirements/local.txt
pytest .
- name: Build Docker image
uses: docker/build-push-action@v4
with:
file: "./compose/local/auth/Dockerfile"
push: ${{ github.event_name != 'pull_request' }}
tags: |
ghcr.io/stranded-in-python/movix-auth:dev
labels: |
maintainer=${{ github.actor }}
build-date=${{ github.event.head_commit.timestamp }}
builder:
environment: production
runs-on: ubuntu-latest
if: ${{ github.event_name != 'pull_request' }}
needs:
- pytest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Login to GHCR
if: github.event_name != 'pull_request'
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.TOKEN }}
- name: Build Docker image
uses: docker/build-push-action@v4
with:
file: "./compose/production/auth/Dockerfile"
push: ${{ github.event_name != 'pull_request' }}
tags: |
ghcr.io/stranded-in-python/movix-api:latest
labels: |
maintainer=${{ github.actor }}
build-date=${{ github.event.head_commit.timestamp }}