release #392
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |