5 cleanup hacks #61
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: Build, Test, and Release | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
merge_group: | |
env: | |
REGISTRY_USER: ${{ github.actor }} | |
REGISTRY_PASSWORD: ${{ github.token }} | |
IMAGE_REGISTRY: ghcr.io/${{ github.repository }} | |
TEST_IMAGE: ghcr.io/${{ github.repository }}:${{ github.sha }} | |
jobs: | |
build-and-test: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Clone repository | |
uses: actions/checkout@v4 | |
- name: Build Image | |
run: docker build -f image/Containerfile -t ${{ env.TEST_IMAGE }} ./image | |
- name: Set up Go | |
uses: actions/setup-go@v5 | |
with: | |
go-version-file: test/go.mod | |
cache-dependency-path: test/go.sum | |
- name: Build Tests | |
run: cd ./test && go test -c . | |
- name: Execute Tests | |
run: > | |
docker run --rm | |
-v $(pwd)/test:/test | |
--privileged | |
--security-opt="label=disable" ${{ env.TEST_IMAGE }} | |
/bin/sh -c "(/usr/bin/kind create cluster -v 2147483647 --config ./test/kind-in-podman.yaml --wait 60s --retain || (cat $(kind export logs) && podman ps -a)) | |
&& kubectl get no -o wide | |
&& kubectl get ns | |
&& cd ./test && ./test.test -test.v" | |
release: | |
runs-on: ubuntu-latest | |
needs: build-and-test | |
if: ${{ always() && format('refs/heads/{0}', github.event.repository.default_branch) == github.ref }} | |
steps: | |
- name: Log in to ghcr.io | |
uses: redhat-actions/podman-login@v1 | |
with: | |
username: ${{ env.REGISTRY_USER }} | |
password: ${{ env.REGISTRY_PASSWORD }} | |
registry: ${{ env.IMAGE_REGISTRY }} | |
- name: Push image | |
run: podman push ${{ env.TEST_IMAGE }} docker://${{ env.IMAGE_REGISTRY }}:latest |