Build and Push PF_RING modules #4
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 and Push PF_RING modules | |
on: | |
workflow_dispatch: | |
jobs: | |
prepare-matrix: | |
runs-on: ubuntu-latest | |
outputs: | |
versions: ${{ steps.set-matrix.outputs.versions }} | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Prepare list of versions | |
id: set-matrix | |
run: | | |
echo "Listing kernel modules..." | |
versions=(); | |
for f in $(ls modules/ko/*.ko); do | |
version=$(echo $f | sed -E 's/.*pf-ring-(.*)\.ko/\1/'); | |
versions+=("$version") | |
done | |
versions_json=$(echo "${versions[@]}" | tr -d '\n' | jq -R -s -c 'split(" ")') | |
echo "versions=${versions_json}" >> $GITHUB_OUTPUT | |
build-and-push-container-per-module: | |
needs: prepare-matrix | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
version: ${{ fromJson(needs.prepare-matrix.outputs.versions) }} | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to DockerHub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Build and push | |
uses: docker/build-push-action@v5 | |
with: | |
context: ./modules | |
file: ./modules/Dockerfile.single | |
push: true | |
tags: kubeshark/pf-ring-module:${{ matrix.version }} | |
build-args: | | |
KERNEL_VERSION=${{ matrix.version }} | |
build-and-push-container-with-all-modules: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to DockerHub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Docker meta | |
id: meta | |
uses: docker/metadata-action@v4 | |
with: | |
images: kubeshark/pf-ring-module | |
tags: | | |
type=raw,value={{date 'YYYYMMDD'}} | |
type=raw,value=all | |
- name: Build and push | |
uses: docker/build-push-action@v5 | |
with: | |
context: ./modules | |
file: ./modules/Dockerfile.all | |
push: true | |
tags: ${{ steps.meta.outputs.tags }} | |
upload-modules-to-s3: | |
runs-on: ubuntu-latest | |
permissions: | |
id-token: write | |
contents: read | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Configure AWS credentials | |
uses: aws-actions/configure-aws-credentials@v1-node16 | |
with: | |
role-to-assume: ${{ secrets.AWS_ASSUME_ROLE_ARN }} | |
role-session-name: buildsession | |
aws-region: us-east-2 | |
- name: Copy kernel modules | |
run: | | |
versions=(); | |
for f in $(ls modules/ko/*.ko); do | |
version=$(echo $f | sed -E 's/.*pf-ring-(.*)\.ko/\1/'); | |
aws s3 cp $f ${{ secrets.AWS_PF_RING_BUCKET }}/${version}/pf_ring.ko | |
versions+=("$version") | |
done | |
versions_json=$(echo "${versions[@]}" | tr -d '\n' | jq -R -s -c 'split(" ")') | |
echo "Copy versions metadata" | |
echo ${versions_json} > versions.json | |
aws s3 cp versions.json ${{ secrets.AWS_PF_RING_BUCKET }}/meta/versions.json |