Skip to content

.github: merge ci.yaml and publish_docker.yaml #11

.github: merge ci.yaml and publish_docker.yaml

.github: merge ci.yaml and publish_docker.yaml #11

Workflow file for this run

name: ci
on:
push:
pull_request:
env:
ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION: true
PLATFORMS: linux/amd64
permissions:
packages: write
jobs:
make_check:
runs-on: ubuntu-22.04
steps:
- name: "Checkout sfunnel"
uses: actions/checkout@v4
with:
path: sfunnel
fetch-depth: 0
fetch-tags: 1
- name: "Install deps..."
run: |
sudo add-apt-repository universe
sudo apt-get update
sudo apt-get install -y clang make iproute2 bridge-utils python3 \
python3-scapy python3-pip libbpf-dev \
libelf-dev linux-headers-generic \
linux-libc-dev llvm iptables
sudo pip3 install pytest
sudo ln -s /usr/include/x86_64-linux-gnu/asm /usr/include/asm
- name: "Allow test traffic in iptables/nftables"
run: |
sudo iptables -L -n
sudo iptables -t nat -L -n
sudo iptables -I FORWARD -s 11.1.1.1 -j ACCEPT
- name: "Run tests..."
run: cd sfunnel/test && make
docker_build_and_publish:
needs: [make_check]
runs-on: ubuntu-22.04
steps:
- name: "Checkout sfunnel"
uses: actions/checkout@v4
with:
path: sfunnel
fetch-depth: 0
fetch-tags: 1
- name: "Set up Docker buildx"
uses: docker/setup-buildx-action@v3
- name: "Login to GitHub Container Registry (ghcr.io)"
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{github.actor}}
password: ${{secrets.GITHUB_TOKEN}}
- name: "Build and push to ghcr"
run: |
#Cross-build
cd sfunnel
echo "Fix mess with tags in actions/checkout..."
git fetch -f && git fetch -f --tags
export TAG=$(git describe HEAD | sed 's/-.*$//g' | tr -d "v")
EXACT_TAG=$(git describe --exact-match --match "v*" || echo "")
if [[ "${EXACT_TAG}" != "" ]]; then
echo "Cross-building and PUSHING!"
docker buildx build --platform ${PLATFORMS} --push -f docker/Dockerfile . --tag ghcr.io/${GITHUB_REPOSITORY}:${TAG}
else
echo "Cross-building ONLY"
docker buildx build --platform ${PLATFORMS} -f docker/Dockerfile .
fi