-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Peter Motičák <[email protected]>
- Loading branch information
Showing
2 changed files
with
73 additions
and
1 deletion.
There are no files selected for viewing
2 changes: 1 addition & 1 deletion
2
.github/workflows/build-images.yml → .github/workflows/build-images-dockerhub.yml
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
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: | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
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 | ||
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" |