-
Notifications
You must be signed in to change notification settings - Fork 38
106 lines (95 loc) · 3.35 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
94
95
96
97
98
99
100
101
102
103
104
105
106
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"
postgres-version:
description: "The postgres version to set up."
type: number
required: false
default: 17
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 }}
postgres-version: ${{ inputs.postgres-version }}
build:
runs-on: ubuntu-22.04
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: 🐍 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
sed -i '1d' requirements.txt # Remove 1st line (contains package index)
- name: 🏗️ Collect Static Files
run: pipenv run python ./manage.py collectstatic --noinput --clear
- name: 📤 Upload Build Artifact
uses: ocadotechnology/codeforlife-workspace/.github/actions/service/upload-build-artifact@main
with:
path: |
requirements.txt
static/
release:
concurrency: release
runs-on: ubuntu-22.04
needs: [build]
env:
DEPLOY_ARTIFACT_PATH: ".deploy"
steps:
- name: 🛫 Set up Release
uses: ocadotechnology/codeforlife-workspace/.github/actions/service/setup-release@main
with:
cfl-bot-gh-token: ${{ secrets.CFL_BOT_GH_TOKEN }}
- name: 📥 Download Build Artifact
uses: actions/download-artifact@v4
with:
name: build
- name: 📁 Zip Static Files
working-directory: static
run: zip --quiet --recurse-paths ../static.zip .
- name: 🚀 Publish Semantic Release
uses: ocadotechnology/codeforlife-workspace/.github/actions/service/release@main
with:
cfl-bot-gh-token: ${{ secrets.CFL_BOT_GH_TOKEN }}
rc-path: backend.releaserc.json