forked from canonical/lxd-ci
-
Notifications
You must be signed in to change notification settings - Fork 0
103 lines (89 loc) · 2.95 KB
/
image-ubuntu.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
92
93
94
95
96
97
98
99
100
101
102
103
name: Build Ubuntu Images
on:
schedule:
- cron: '0 0 * * *' # Build amd64 (Daily at 00:00 UTC).
workflow_dispatch:
inputs:
publish:
type: boolean
default: false
description: Publish built image
jobs:
ubuntu:
if: github.event_name != 'schedule' || github.repository == 'canonical/lxd-ci'
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
release:
- focal
- jammy
- noble
variant:
- desktop
# - default
# - cloud
architecture:
- amd64
# - arm64
exclude:
- {variant: desktop, architecture: arm64}
env:
type: "container"
distro: "${{ github.job }}"
target: "${HOME}/build"
steps:
- uses: actions/checkout@v4
- name: Setup environment
uses: ./.github/actions/image-setup
- name: Determine image types
run: |
ARCH="${{ matrix.architecture }}"
if [ "${ARCH}" = "amd64" ]; then
echo "type=container,vm" >> $GITHUB_ENV
fi
if [ "${{ matrix.variant }}" = "desktop" ]; then
echo "type=vm" >> $GITHUB_ENV
fi
- name: Build image
run: |
TIMEOUT=3600
YAML="${{ github.workspace }}/images/${{ env.distro }}.yaml"
ARCH="${{ matrix.architecture }}"
TYPE="${{ env.type }}"
ARCHIVE="http://archive.ubuntu.com/ubuntu"
if [ "${ARCH}" != "amd64" ] && [ "${ARCH}" != "i386" ]; then
ARCHIVE="http://ports.ubuntu.com/ubuntu-ports"
fi
./bin/build-distro "${YAML}" "${ARCH}" "${TYPE}" "${TIMEOUT}" "${{ env.target }}" \
-o image.architecture=${{ matrix.architecture }} \
-o image.release=${{ matrix.release }} \
-o image.variant=${{ matrix.variant }} \
-o source.url="${ARCHIVE}"
- name: Print build artifacts
run: ls -lah "${{ env.target }}"
- name: Test container image
uses: ./.github/actions/image-test
if: contains(env.type, 'container')
with:
type: container
target: ${{ env.target }}
distro: ${{ env.distro }}
release: ${{ matrix.release }}
variant: ${{ matrix.variant }}
- name: Test VM image
uses: ./.github/actions/image-test
if: contains(env.type, 'vm')
with:
type: vm
target: ${{ env.target }}
distro: ${{ env.distro }}
release: ${{ matrix.release }}
variant: ${{ matrix.variant }}
- name: Upload image
uses: ./.github/actions/image-upload
if: github.event_name == 'schedule' || inputs.publish == true
with:
target: ${{ env.target }}
image_dir: "${{ env.distro }}/${{ matrix.release }}/${{ matrix.architecture }}/${{ matrix.variant }}"
ssh_private_key: "${{ secrets.LXD_INFRA_IMAGES_KEY }}"