Skip to content

release

release #449

Workflow file for this run

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
wget https://github.com/mikefarah/yq/releases/download/v4.20.1/yq_linux_amd64 -O yq
chmod +x yq
sudo chown root:root yq
sudo mv yq /usr/bin/yq
- id: set-matrix
run: |
echo "::set-output name=matrix::{\"image\": $(make images-json)}"
release-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
wget https://github.com/mikefarah/yq/releases/download/v4.20.1/yq_linux_amd64 -O yq
chmod +x yq
sudo chown root:root yq
sudo mv yq /usr/bin/yq
- name: Make build image ${{ matrix.image }}
run: |
IMAGES=${{ matrix.image }} make build
- name: Install microk8s
run: |
sudo snap install microk8s --channel 1.25-strict/stable
sudo microk8s.status --wait-ready
sudo microk8s.enable storage dns
sudo microk8s.status --wait-ready
sudo usermod -a -G snap_microk8s $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 refresh juju --channel=${juju_test_channel}
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: |
sg snap_microk8s <<'EOF'
juju bootstrap microk8s
juju status -m controller
image_tag="$(microk8s.kubectl -n controller-microk8s-localhost get pod controller-0 -o json | jq -r '.status.containerStatuses | map(select(.name=="mongodb"))[0].image')"
expected_image_id="$(docker inspect ${image_tag} --format {{.ID}})"
got_image_id="$(microk8s.kubectl -n controller-microk8s-localhost get pod controller-0 -o json | jq -r '.status.containerStatuses | map(select(.name=="mongodb"))[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