forked from Lintuasemasovellus/lintuasemasovellus
-
Notifications
You must be signed in to change notification settings - Fork 2
105 lines (96 loc) · 2.87 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
name: Run Tests and Publish Docker Image
on:
push:
branches: [ master, dev ]
pull_request:
branches: [ master, dev ]
types: [ opened, synchronize ]
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
tests:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.6'
- name: Install backend dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
working-directory: ./lintuasema-backend
- name: Test backend with pytest
run: |
python3 -m pytest
working-directory: ./lintuasema-backend
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '12.x'
- name: Install frontend packages
run: npm install
working-directory: ./frontend
- name: Run frontend tests
run: npm test
working-directory: ./frontend
- name: Build & copy frontend to backend
run: npm run build-copy
working-directory: ./frontend
- name: Run backend
env:
AUTH_TOKEN: ${{ secrets.TEST_CONFIG_AUTH_TOKEN }}
TARGET: ${{ secrets.TEST_CONFIG_TARGET }}
run: flask run --port=3000 &
working-directory: ./lintuasema-backend
- name: Run Cypress tests
env:
cypress_person_token: ${{ secrets.CYPRESS_PERSON_TOKEN }}
run: |
sleep 10
npm run cypress:cmd
working-directory: ./frontend
- name: Save Cypress screenshots if fails
uses: actions/upload-artifact@v4
if: failure()
with:
name: cypress-screenshots
path: frontend/cypress/screenshots/
- name: Save Cypress videos if fails
uses: actions/upload-artifact@v4
if: failure()
with:
name: cypress-videos
path: frontend/cypress/videos/
build:
if: ${{ github.event_name == 'push' && contains(join(github.event.commits.*.message, ', '), '#skip') == false }}
needs: [tests]
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
- name: Buildah Action
id: build_image
uses: redhat-actions/buildah-build@v2
with:
image: ${{ env.IMAGE_NAME }}
tags: ${{ steps.meta.outputs.tags }}
oci: true
containerfiles: |
./Dockerfile
- name: Push To GHCR
uses: redhat-actions/push-to-registry@v2
with:
tags: ${{ steps.build_image.outputs.tags }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}