-
Notifications
You must be signed in to change notification settings - Fork 4
156 lines (127 loc) · 4.41 KB
/
main.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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
name: Prophecies - CI
on:
push:
concurrency:
group: '${{ github.workflow }} @ ${{ github.head_ref || github.ref }}'
cancel-in-progress: true
jobs:
lint-backend:
uses: ./.github/workflows/python_task.yml
with:
python-version: '["3.10"]'
command: poetry run pylint prophecies
test-backend:
uses: ./.github/workflows/python_task.yml
with:
python-version: '["3.10", "3.11", "3.12"]'
command: make test-back
test-frontend:
uses: ./.github/workflows/node_task.yml
with:
node-version: '["16.x", "18.x"]'
command: make test-front
build:
runs-on: ubuntu-latest
needs: [lint-backend, test-backend, test-frontend]
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.10
uses: actions/setup-python@v4
with:
python-version: "3.10"
- name: Install Poetry
uses: snok/install-poetry@v1
with:
virtualenvs-create: true
virtualenvs-in-project: true
installer-parallel: true
- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v3
with:
path: .venv
key: venv-${{ runner.os }}-3.10-${{ hashFiles('**/poetry.lock') }}
- name: Install Python dependencies
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: poetry install --no-interaction --no-root
- name: Create a docs directory
run: mkdir ./docs
- name: Save OpenAPI schema
run: poetry run python manage.py spectacular --file ./openapi-${GITHUB_SHA}.yml
- name: Upload OpenAPI schema to repository's artifacts
uses: actions/upload-artifact@v4
with:
name: openapi-schemas
path: |
openapi-*.yml
- name: Move and rename OpenAPI schema file to omit the SHA
run: mv openapi-${GITHUB_SHA}.yml prophecies/static/docs/openapi.yml
- name: Fix permissions for Github Pages
run: |
chmod -c -R +rX "prophecies/static/docs/" | while read line; do
echo "::warning title=Invalid file permissions automatically fixed::$line"
done
- name: Upload docs directory to github-pages artifacts
uses: actions/upload-pages-artifact@v3
with:
path: prophecies/static/docs/
docs-publish:
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
needs: [build]
permissions:
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Deploy artifact from "github-pages" to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
package-publish:
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
needs: [build]
steps:
- name: Download all OpenAPI schema artifacts
uses: actions/download-artifact@v4
with:
name: openapi-schemas
- name: Prepare tag name
id: prep
run: echo "TAG_NAME=$(echo ${GITHUB_REF#refs/tags/v})" >> $GITHUB_ENV
- name: Rename OpenAPI schema file to something human readable
run: mv openapi-${GITHUB_SHA}.yml openapi.yml
- name: Create the release package
uses: softprops/action-gh-release@v1
with:
prerelease: false
generate_release_notes: true
files: openapi.yml
docker-publish:
needs: [build]
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- name: Prepare tag name
id: prep
run: echo "TAG_NAME=$(echo ${GITHUB_REF#refs/tags/v})" >> $GITHUB_ENV
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: icij/prophecies:${{ env.TAG_NAME }},icij/prophecies:latest
platforms: linux/amd64,linux/arm64