-
Notifications
You must be signed in to change notification settings - Fork 0
67 lines (54 loc) · 1.61 KB
/
ci_cd.yaml
File metadata and controls
67 lines (54 loc) · 1.61 KB
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
name: CI/CD Pipeline
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
build-test:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Install Nix
uses: cachix/install-nix-action@v17
with:
nix_path: nixpkgs=channel:nixos-25.05
- name: Build Nix package
run: nix build
publish:
permissions:
contents: read
packages: write
needs: build-test
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Install Nix
uses: cachix/install-nix-action@v17
with:
nix_path: nixpkgs=channel:nixos-25.05
- name: Build Docker image
run: nix build .#image
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Load Docker image
run: docker load < result
- name: Extract version
id: version
run: |
echo "VERSION=$(nix eval --raw .#default.version)" >> $GITHUB_ENV
- name: Tag Docker image for GHCR
run: |
# on met l'owner en minuscules
owner=${GITHUB_REPOSITORY_OWNER,,}
docker tag basic_python_app:${VERSION} ghcr.io/${owner}/basic_python_app:${VERSION}
- name: Push to GHCR
run: |
owner=${GITHUB_REPOSITORY_OWNER,,}
docker push ghcr.io/${owner}/basic_python_app:${VERSION}