Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Build Images
name: Build Images (Docker Hub)

on:
pull_request:
Expand Down
73 changes: 73 additions & 0 deletions .github/workflows/build-images-ghcr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: Build Images (ghcr.io)

on:
pull_request:
branches:
- master
push:
branches:
- master
schedule:
- cron: '0 */12 * * *'
workflow_dispatch:

jobs:
build-images:
name: "VPP ${{ matrix.tag }}"
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
env:
REGISTRY: ghcr.io
IMG_NAME: ${{ github.repository }}
REPO: ${{ matrix.repo }}
TAG: ${{ matrix.tag }}
strategy:
fail-fast: false
matrix:
tag: ['master', 'latest', '23.02', '22.10', '22.06', '22.02']
include:
- tag: 'master'
repo: 'master'
- tag: 'latest'
repo: 'release'
- tag: '23.02'
repo: '2302'
- tag: '22.10'
repo: '2210'
- tag: '22.06'
repo: '2206'
- tag: '22.02'
repo: '2202'

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Build image
run: |
env | sort
docker build --build-arg REPO="$REPO" --tag "$REGISTRY/$IMG_NAME:$TAG" .
docker run --rm "$REGISTRY/$IMG_NAME:$TAG" dpkg-query -f '${Version}' -W vpp
VPP_VERSION=$(docker run --rm "$REGISTRY/$IMG_NAME:$TAG" cat /vpp/version | cut -d'~' -f1,2 | sed -e 's/~/./g')
echo "VPP_VERSION=$VPP_VERSION" >> $GITHUB_ENV

- name: Check if image already published
if: github.event_name != 'pull_request'
run: |
docker tag "$REGISTRY/$IMG_NAME:$TAG" "$REGISTRY/$IMG_NAME:${{ env.VPP_VERSION }}"
docker images "$REGISTRY/$IMG_NAME"
GHCR_TOKEN=$(echo ${{ secrets.GITHUB_TOKEN }} | base64)
if [ ${{ github.event_name }} == "schedule" ] \
&& curl --head --fail -H "Authorization: Bearer ${GHCR_TOKEN}" https://$REGISTRY/v2/$IMG_NAME/manifests/${{ env.VPP_VERSION }}; then
echo "Image $REGISTRY/$IMG_NAME:${{ env.VPP_VERSION }} has already been published"
exit 1
fi

- name: Publish image
if: github.event_name != 'pull_request' && success()
run: |
echo "${{ secrets.GITHUB_TOKEN }}" | docker login "$REGISTRY" -u "${{ github.actor }}" --password-stdin
docker push "$REGISTRY/$IMG_NAME:${{ env.VPP_VERSION }}"
docker push "$REGISTRY/$IMG_NAME:$TAG"