Test via GitHub actions #7
Workflow file for this run
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: | |
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: podman build --format docker -f image/Containerfile -t ${{ env.TEST_IMAGE }} ./image | |
- name: Execute Tests | |
run: > | |
podman 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 --retain || kind export logs) | |
&& kubectl get no -o wide | |
&& kubectl get ns | |
&& cd ./test && go test . -v" | |
release: | |
runs-on: ubuntu-latest | |
needs: build-and-test | |
if: ${{ format('refs/heads/{0}', github.event.repository.default_branch) == github.ref }} # only relase on master | |
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 |