-
Notifications
You must be signed in to change notification settings - Fork 0
62 lines (60 loc) · 1.77 KB
/
Copy pathcheck.yml
File metadata and controls
62 lines (60 loc) · 1.77 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
name: "Check"
on:
push:
pull_request:
workflow_dispatch:
jobs:
check:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@main
- name: Install nix
uses: cachix/install-nix-action@master
with:
github_access_token: '${{ secrets.GITHUB_TOKEN }}'
- name: Setup cachix
uses: cachix/cachix-action@master
with:
name: linyinfeng
signingKey: '${{ secrets.CACHIX_SIGNING_KEY }}'
- name: Nix flake check
run: nix flake check
upload-docker-image:
if: ${{ github.event_name == 'push' }}
runs-on: ubuntu-latest
needs: check
permissions:
contents: read
packages: write
outputs:
image_tag: ${{ steps.upload.outputs.image_tag }}
steps:
- name: Checkout
uses: actions/checkout@main
- name: Install nix
uses: cachix/install-nix-action@master
with:
github_access_token: '${{ secrets.GITHUB_TOKEN }}'
- name: Setup cachix
uses: cachix/cachix-action@master
with:
name: linyinfeng
signingKey: '${{ secrets.CACHIX_SIGNING_KEY }}'
- name: Upload docker image
id: upload
run: |
image_archive=$(nix build .#dockerImage --no-link --print-out-paths)
function push_to {
echo "push to '$1'"
skopeo copy \
--dest-creds "${{ github.actor }}:${{ secrets.GITHUB_TOKEN }}" \
"docker-archive:$image_archive" \
"$1"
}
tag=$(nix eval .#dockerImage.imageTag --raw)
echo "image_tag=$tag" >> $GITHUB_OUTPUT
push_to "docker://ghcr.io/linyinfeng/commit-notifier:$tag"
if [ "${{ github.ref }}" = "refs/heads/main" ]; then
push_to "docker://ghcr.io/linyinfeng/commit-notifier:latest"
fi