-
Notifications
You must be signed in to change notification settings - Fork 4
73 lines (60 loc) · 2.46 KB
/
component.yml
File metadata and controls
73 lines (60 loc) · 2.46 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
68
69
70
71
72
73
---
name: Component
on:
workflow_call:
inputs:
component:
required: true
type: string
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dorny/paths-filter@v3
id: filter
with:
filters: |
component:
# Flake
- '**/*.nix'
- 'flake.lock'
# Cargo common
- 'Cargo.toml'
- 'Cargo.lock'
# Rust common
- 'common/Cargo.toml'
- 'common/**/*.rs'
- 'streaming-types/Cargo.toml'
- 'streaming-types/**/*.rs'
# Component
- "${{ inputs.component }}/default.nix"
- "${{ inputs.component }}/Cargo.toml"
- "${{ inputs.component }}/**/*.rs"
- uses: DeterminateSystems/nix-installer-action@v16
# Evaluate the devshell here so that the time reported for subsequent
# steps that use it reflect what is actually done there.
- name: Evaluate devshell
if: steps.filter.outputs.component == 'true'
run: nix develop
- name: Build
if: steps.filter.outputs.component == 'true'
run: nix build -L .#${{ inputs.component }}
- name: Build and push container image
if: steps.filter.outputs.component == 'true' && (github.ref_name == 'main' || github.ref_type == 'tag')
run: |
set -x
# Build image via Nix and take the resulting path as the local container registry
local_cr="docker-archive://$(nix build .#${{ inputs.component }}-container-image --no-link --print-out-paths)"
# The container registry to push images to (GHCR)
remote_cr="docker://ghcr.io/stfc-icd-research-and-design/supermusr-${{ inputs.component }}"
remote_cr_creds="${{ github.repository_owner }}:${{ github.token }}"
# Push image using the Git ref name as the image tag (i.e. "main" or the tag name)
skopeo copy --dest-creds="$remote_cr_creds" "$local_cr" "$remote_cr:${{ github.ref_name }}"
# Push image using the Git SHA as the image tag
skopeo copy --dest-creds="$remote_cr_creds" "$local_cr" "$remote_cr:${{ github.sha }}"
# If the trigger was a tag (i.e. a release)
if [[ "${{ github.ref_type }}" == 'tag' ]]; then
skopeo copy --dest-creds="$remote_cr_creds" "$local_cr" "$remote_cr:latest"
fi