1+ name : Backend main workflow
2+
3+ on :
4+ push :
5+ branches :
6+ - main
7+ paths :
8+ - ' backend/**'
9+ pull_request :
10+ branches :
11+ - main
12+ paths :
13+ - ' backend/**'
14+
15+ jobs :
16+ build-test-deploy :
17+ runs-on : ubuntu-latest
18+
19+ steps :
20+ - name : Checkout code
21+ uses : actions/checkout@v4
22+
23+ - name : Set up Python
24+ uses : actions/setup-python@v4
25+ with :
26+ python-version : 3.11
27+
28+ - name : Install dependencies (Poetry)
29+ run : |
30+ cd backend
31+ curl -sSL https://install.python-poetry.org | python3 -
32+ export PATH="$HOME/.local/bin:$PATH"
33+ poetry install
34+
35+ - name : Run tests
36+ run : |
37+ cd backend
38+ poetry run pytest --maxfail=1 --disable-warnings -q
39+
40+ - name : Log in to Docker Hub
41+ uses : docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a
42+ with :
43+ username : ${{ secrets.DOCKER_USERNAME }}
44+ password : ${{ secrets.DOCKER_PASSWORD }}
45+
46+ - name : Log in to the Container registry
47+ uses : docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
48+ with :
49+ registry : ghcr.io
50+ username : ${{ github.actor }}
51+ password : ${{ secrets.GHCR_TOKEN }}
52+
53+ - name : Extract metadata (tags, labels) for Docker
54+ id : meta
55+ uses : docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
56+ with :
57+ images : |
58+ cpprian/encrypted-notes-manager-backend
59+ ghcr.io/${{ github.repository }}-backend
60+
61+ - name : Build and push Docker images
62+ id : push
63+ uses : docker/build-push-action@3b5e8027fcad23fda98b2e3ac259d8d67585f671
64+ with :
65+ context : ./backend
66+ push : true
67+ tags : ${{ steps.meta.outputs.tags }}
68+ labels : ${{ steps.meta.outputs.labels }}
69+
70+ - name : Generate artifact attestation
71+ uses : actions/attest-build-provenance@v3
72+ with :
73+ subject-name : ghcr.io/${{ github.repository }}
74+ subject-digest : ${{ steps.push.outputs.digest }}
75+ push-to-registry : true
76+
0 commit comments