-
Notifications
You must be signed in to change notification settings - Fork 6
129 lines (114 loc) · 4.4 KB
/
release.yaml
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
name: release
on:
push:
branches:
- "master"
schedule:
- cron: "15 0 * * *"
jobs:
generate-matrix:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Install dependencies
run: |
sudo apt update
sudo apt install -y make jq
sudo snap install yq
- id: set-matrix
run: |
echo "::set-output name=matrix::{\"image\": $(make images-json)}"
push-docker-image:
needs: generate-matrix
runs-on: ubuntu-latest
strategy:
matrix: ${{ fromJSON(needs.generate-matrix.outputs.matrix) }}
steps:
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
with:
config-inline: |
[worker.oci]
max-parallelism = 1
- name: Checkout
uses: actions/checkout@v2
- name: Install dependencies
run: |
sudo apt update
sudo apt install -y make jq
sudo snap install yq
- name: Make build image ${{ matrix.image }}
run: |
IMAGES=${{ matrix.image }} make build
- name: Install microk8s
run: |
microk8s_test_channel=$(yq ".images.[\"${{ matrix.image }}\"].microk8s_test_channel" < images.yaml)
sudo snap install microk8s --channel=${microk8s_test_channel} || sudo snap install microk8s --channel=${microk8s_test_channel} --classic
sudo microk8s.status --wait-ready
sudo microk8s.enable storage dns
sudo microk8s.status --wait-ready
microk8s_group=microk8s
if getent group snap_microk8s; then
microk8s_group=snap_microk8s
fi
sudo usermod -a -G "${microk8s_group}" $USER
- name: Install juju snap
run: |
juju_test_channel=$(yq ".images.[\"${{ matrix.image }}\"].juju_test_channel" < images.yaml)
sudo snap install juju --channel=${juju_test_channel} || sudo snap install juju --channel=${juju_test_channel} --classic
echo "installed juju $(juju version)"
- name: Copy built image to microk8s.ctr
run: |
IMAGES=${{ matrix.image }} make microk8s-image-update
- name: Bootstrap juju into microk8s
run: |
microk8s_group=microk8s
if getent group snap_microk8s; then
microk8s_group=snap_microk8s
fi
sg "${microk8s_group}" <<'EOF'
series=$(yq ".images.[\"${{ matrix.image }}\"].series" < images.yaml)
juju bootstrap microk8s
juju status -m controller
juju add-model test
juju deploy ./test-charm --series "${series}"
until juju status | grep -q "Image is all good."; do
sleep 1
juju status
done
image_tag="$(microk8s.kubectl -n test get pod ubuntu-test-0 -o json | jq -r '.status.containerStatuses | map(select(.name=="charm"))[0].image')"
expected_image_id="$(docker inspect ${image_tag} --format {{.ID}})"
got_image_id="$(microk8s.kubectl -n test get pod ubuntu-test-0 -o json | jq -r '.status.containerStatuses | map(select(.name=="charm"))[0].imageID')"
echo "image ${image_tag} built as ${expected_image_id}"
echo "image ${image_tag} used as ${got_image_id}"
if [ "${expected_image_id}" != "${got_image_id}" ]; then
echo "${got_image_id} does not match expected ${expected_image_id}"
exit 1
fi
EOF
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Login to ECR Public
uses: docker/login-action@v3
with:
registry: public.ecr.aws
username: ${{ secrets.RELEASE_ECR_ACCESS_KEY_ID }}
password: ${{ secrets.RELEASE_ECR_SECRET_ACCESS_KEY }}
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Push images
if: ${{ success() && github.ref == 'refs/heads/master' }}
run: |
IMAGES=${{ matrix.image }} make push