Build, Test, and Release #174
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: | |
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: Configure | |
run: | | |
sudo apt update | |
sudo apt install -y fuse-overlayfs podman containernetworking-plugins containers-storage | |
sudo cp /usr/share/containers/storage.conf /etc/containers/storage.conf | |
sudo sed -i 's/#mount_program/mount_program/' /etc/containers/storage.conf | |
sudo podman system reset --force | |
sudo mkdir -p /etc/systemd/system/[email protected]/ | |
sudo touch /etc/systemd/system/[email protected]/delegate.conf | |
echo [Service] | sudo tee -a /etc/systemd/system/[email protected]/delegate.conf | |
echo Delegate=yes | sudo tee -a /etc/systemd/system/[email protected]/delegate.conf | |
sudo systemctl daemon-reload | |
- 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 --wait 60s | |
&& kubectl get no -o wide | |
&& kubectl get ns | |
&& cd ./test && go 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 |