-
Notifications
You must be signed in to change notification settings - Fork 34
93 lines (83 loc) · 2.78 KB
/
backend.yaml
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
name: Backend
on:
workflow_call:
inputs:
python-version:
description: "The Python version to set up."
type: number
required: false
default: 3.12
# TODO: remove this after restructure and standardize source path.
source-path:
description: "The path to the source files."
type: string
required: false
default: "api"
postgres-db:
description: "The postgres database to test against."
type: string
required: false
default: "db"
secrets: # All secrets should not be required to support contributors.
CODECOV_TOKEN:
description: "The token used to gain access to Codecov."
required: false
CFL_BOT_GH_TOKEN:
description: "The CFL-bot's GitHub token. Used to release."
required: false
jobs:
test:
uses: ocadotechnology/codeforlife-workspace/.github/workflows/test-python-code.yaml@main
secrets: inherit
with:
python-version: ${{ inputs.python-version }}
source-path: ${{ inputs.source-path }}
postgres-db: ${{ inputs.postgres-db }}
build:
runs-on: ubuntu-latest
needs: [test]
# Build if:
# - the repo's owner is Ocado Tech.
# - the repo is not the backend template.
# - a change is made to the default branch.
if: |
github.repository_owner_id == 2088731 &&
github.repository_id != 610204172 &&
github.ref_name == github.event.repository.default_branch
steps:
- name: 🛫 Checkout
uses: actions/checkout@v4
- name: 🔎 Check Service Deployment Descriptor
run: |
if [ ! -f .deploy/service.json ]; then
echo "Missing service deployment descriptor."
exit 1
fi
- name: 📤 Upload Deploy Artifact
uses: actions/upload-artifact@v4
with:
name: deploy
path: .deploy/
if-no-files-found: error
include-hidden-files: true
- name: 🐍 Set up Python ${{ inputs.python-version }} Environment
uses: ocadotechnology/codeforlife-workspace/.github/actions/python/setup-environment@main
with:
python-version: ${{ inputs.python-version }}
checkout: false
- name: 🏗️ Generate requirements.txt
run: pipenv requirements > requirements.txt
- name: 🏗️ Collect Static Files
run: pipenv run python ./manage.py collectstatic --noinput --clear
- name: 📤 Upload Build Artifact
uses: actions/upload-artifact@v4
with:
name: build
path: |
requirements.txt
static/
if-no-files-found: error
release:
needs: [build]
uses: ocadotechnology/codeforlife-workspace/.github/workflows/release.yaml@main
secrets: inherit