-
Notifications
You must be signed in to change notification settings - Fork 0
91 lines (76 loc) · 2.14 KB
/
docker-image.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
name: Create and publish a Docker image
on:
push:
branches: [master]
pull_request:
branches: [master]
merge_group:
permissions:
contents: read
packages: write
jobs:
check:
name: Run all tests and checks
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Nix
uses: cachix/install-nix-action@v25
- name: Setup Cachix
uses: cachix/cachix-action@v14
with:
name: wuvt
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
- name: Evaluate Nix checks
run: nix flake check
build-image:
name: Build the Docker image
needs: check
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Nix
uses: cachix/install-nix-action@v25
- name: Setup Cachix
uses: cachix/cachix-action@v14
with:
name: wuvt
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
- name: Build Docker image
run: nix build .#poser-container
- name: Upload the built Docker image
uses: actions/upload-artifact@v4
with:
name: docker
path: result
push-image:
name: Publish the Docker image to GitHub
if: github.event_name != 'merge_group'
needs: build-image
runs-on: ubuntu-latest
steps:
- name: Download the build Docker image
uses: actions/download-artifact@v4
with:
name: docker
- name: Generate tags
id: meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/wuvt/poser
sep-tags: " "
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
- name: Login to GitHub Container Registry
run: skopeo login -u "${{ github.actor }}" -p "${{ secrets.GITHUB_TOKEN }}" ghcr.io
- name: Push Docker image
run: |
for TAG in ${{ steps.meta.outputs.tags }}
do
skopeo copy docker-archive:result "docker://$TAG"
done