-
Notifications
You must be signed in to change notification settings - Fork 3
37 lines (33 loc) · 1.48 KB
/
container.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
name: build container image
on:
pull_request:
push:
branches:
- main
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref || github.run_id }}
cancel-in-progress: true
jobs:
container:
runs-on: ubuntu-22.04
permissions:
id-token: write
contents: read
packages: write
steps:
- uses: actions/checkout@main
- uses: DeterminateSystems/nix-installer-action@main
- uses: DeterminateSystems/magic-nix-cache-action@main
- name: Set up nix dev env
run: nix develop --command echo 0
- name: Build container image
run: nix build .#container
- name: Push container image on commits to main
if: ${{ github.ref_name == 'main' }}
run: |
nix develop --ignore-environment --command skopeo copy --dest-creds="${{ github.repository_owner }}:${{ github.token }}" docker-archive:./result docker://ghcr.io/javierhonduco/lightswitch:main-${{ github.sha }}
- name: Push container image on new releases
if: ${{ github.ref_type == 'tag' }}
run: |
nix develop --ignore-environment --command skopeo copy --dest-creds="${{ github.repository_owner }}:${{ github.token }}" docker-archive:./result docker://ghcr.io/javierhonduco/lightswitch:${{ github.ref_name }}
nix develop --ignore-environment --command skopeo copy --dest-creds="${{ github.repository_owner }}:${{ github.token }}" docker-archive:./result docker://ghcr.io/javierhonduco/lightswitch:latest