[deps]: Lock file maintenance (#34) #139
This file contains hidden or 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: Build GHCR | |
on: | |
push: | |
paths-ignore: | |
- ".github/workflows/**" | |
workflow_dispatch: | |
jobs: | |
build-docker: | |
name: Build Docker images | |
runs-on: ubuntu-22.04 | |
env: | |
_GHCR_REGISTRY: ghcr.io/bitwarden | |
_PROJECT_NAME: sm-operator | |
steps: | |
- name: Checkout repo | |
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@68827325e0b33c7199eb31dd4e31fbe9023e06e3 #v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@d70bba72b1f3fd22344832f00baa16ece964efeb #v3 | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@0d4c9c5ea7693da7b068278f7b52bda2a190a446 # v3.2.0 | |
with: | |
registry: ghcr.io | |
username: ${{github.actor}} | |
password: ${{secrets.GITHUB_TOKEN}} | |
- name: Test operator | |
id: test | |
run: | | |
sudo apt update && sudo apt install musl-tools -y | |
make setup | |
make test | |
go tool cover -html=cover.out -o=cover.html | |
- name: Upload test coverage report artifact | |
uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3 | |
with: | |
name: cover.html | |
path: cover.html | |
if-no-files-found: error | |
- name: Generate Docker image tag | |
id: tag | |
run: | | |
IMAGE_TAG=$(echo "${GITHUB_REF:11}" | sed "s#/#-#g") # slash safe branch name | |
if [[ "$IMAGE_TAG" == "main" ]]; then | |
IMAGE_TAG=dev | |
fi | |
echo "image_tag=$IMAGE_TAG" >> $GITHUB_OUTPUT | |
- name: Generate image full name | |
id: image-name | |
env: | |
IMAGE_TAG: ${{ steps.tag.outputs.image_tag }} | |
run: echo "name=${_GHCR_REGISTRY}/${_PROJECT_NAME}:${IMAGE_TAG}" >> $GITHUB_OUTPUT | |
- name: Build Docker image | |
uses: docker/build-push-action@31159d49c0d4756269a0940a750801a1ea5d7003 # v6.1.0 | |
with: | |
file: Dockerfile | |
platforms: linux/amd64,linux/arm64 | |
push: true | |
tags: ${{ steps.image-name.outputs.name }} | |
- name: Create kind cluster | |
uses: helm/kind-action@0025e74a8c7512023d06dc019c617aa3cf561fde # v1.10.0 | |
- name: Smoke Test Image | |
id: smoke-test | |
env: | |
IMAGE: ${{ steps.image-name.outputs.name }} | |
run: | | |
make deploy IMG=$IMAGE | |
count=0 | |
while [[ $(kubectl get pods -n sm-operator-system -l control-plane=controller-manager -o jsonpath="{.items[*].status.containerStatuses[*].ready}") != "true" ]]; do | |
sleep 1; | |
count=$count+1 | |
if [[ count -ge 30 ]]; then | |
break | |
fi | |
done | |
#For review purposes | |
echo "*****DEPLOYMENTS*****" | |
kubectl get deployments -n sm-operator-system | |
echo "*****PODS*****" | |
pods=$(kubectl get pods -n sm-operator-system -l control-plane=controller-manager | grep 2/2) | |
echo $pods | |
if [[ -z "$pods" ]]; then | |
echo "::error::No pods found." | |
exit 1 | |
fi | |
echo "*****OPERATOR OK*****" | |
- name: Clean-up | |
run: | | |
make undeploy | |
kind delete cluster |