Skip to content

add CodeQL badge

add CodeQL badge #305

---
name: Docker
on:
workflow_dispatch:
workflow_call:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
# This is used to complete the identity challenge
# with sigstore/fulcio when running outside of PRs.
id-token: write
steps:
- uses: actions/checkout@v3
- uses: docker/setup-qemu-action@v2
- uses: docker/[email protected]
- name: Log in to Docker Hub
if: github.event_name != 'pull_request'
uses: docker/[email protected]
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Log in to the GH Container registry
if: github.event_name != 'pull_request'
uses: docker/[email protected]
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract Docker metadata
id: meta
uses: docker/[email protected]
with:
images: |
${{ github.repository }}
ghcr.io/${{ github.repository }}
- name: Build and push Docker image
id: build-and-push
uses: docker/[email protected]
with:
context: .
platforms: linux/amd64,linux/arm64
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Update Docker Hub Description
if: github.event_name != 'pull_request'
uses: peter-evans/dockerhub-description@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN_DELETE }}
repository: ${{ github.repository }}
short-description: ${{ github.event.repository.description }}
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: docker/setup-qemu-action@v2
- uses: docker/[email protected]
- name: Install additional kernel modules needed for OPI like VRF
run: sudo apt-get install linux-modules-extra-$(uname -r)
- name: Load additional kernel modules needed for OPI like VRF
run: sudo modprobe -v vrf
- name: Start containers
run: docker-compose up --build --force-recreate --detach opi-test
- name: Run Tests
run: |
set -x
name=$(docker-compose ps | grep opi-test | awk '{print $1}')
rc=$(docker wait "${name}")
if [ "${rc}" != "0" ]; then
echo "opi-test failed:"
docker logs "${name}"
exit 1
fi
- name: Logs
if: always()
run: docker-compose logs
- name: Stop containers
if: always()
run: docker-compose down --volumes --remove-orphans