Skip to content

CI: Push docker image to GHCR #11

CI: Push docker image to GHCR

CI: Push docker image to GHCR #11

Workflow file for this run

---
name: Build Ubuntu/CentOS Docker Image and Push them to Docker registry
on:
push:
branches:
- '*'
workflow_dispatch:
inputs:
OS_FLAVOR:
description: "Linux Flavor"
required: true
type: string
default: ubuntu
env:
DOCKER_REGISTRY: "ghcr.io"
jobs:
builder-docker-image:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Build Ubuntu Docker image
# yamllint disable-line rule:line-length
run: docker build -t ${{ vars.DOCKER_REPOSITORY }}/${{ vars.ODL_BASE_IMAGE_NAME }} \
builder/ubuntu
- name: Clone and test repo
# yamllint disable-line rule:line-length
run: docker run ${{ vars.DOCKER_REPOSITORY }}/${{ vars.ODL_BASE_IMAGE_NAME }} \
bash -c 'git clone "https://git.opendaylight.org/gerrit/integration/distribution" && \
cd /distribution && mvn clean install'
- name: Authenticate to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Push Docker image
# yamllint disable-line rule:line-length
run: docker push ${{ vars.DOCKER_REPOSITORY }}/${{ vars.ODL_BASE_IMAGE_NAME }}
- name: Authenticate and push GHCR
uses: docker/login-action@v1
with:
registry: ${{ env.DOCKER_REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build the hello-docker Docker image
# yamllint disable-line rule:line-length
run: |
docker build . --tag ${{ env.DOCKER_REGISTRY }}/${{ vars.DOCKER_REPOSITORY }}/${{ vars.ODL_BASE_IMAGE_NAME }}:latest
docker run ${{ env.DOCKER_REGISTRY }}/${{ vars.DOCKER_REPOSITORY }}/${{ vars.ODL_BASE_IMAGE_NAME }}:latest
docker push ${{ env.DOCKER_REGISTRY }}/${{ vars.DOCKER_REPOSITORY }}/${{ vars.ODL_BASE_IMAGE_NAME }}:latest
Build-And-Test-Robot-Docker-Image:
runs-on: ubuntu-latest
services:
opendaylight:
image: opendaylight/opendaylight:0.18.1
env:
FEATURES: odl-restconf,odl-netconf-topology
ports:
- 8181:8181
options: --name odl-container
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Build Docker image
run: docker build -t ${{ vars.DOCKER_REPOSITORY }}/${{ vars.ROBOT_BASE_IMAGE_NAME }} robot/
- name: Test
run: |
docker run --network container:odl-container ${{ vars.DOCKER_REPOSITORY }}/${{ vars.ROBOT_BASE_IMAGE_NAME }} bash -c '
yum install -y git python3-pip &&
pip3 install robotframework robotframework-extendedrequestslibrary &&
git clone https://github.com/opendaylight/integration-test.git &&
cd integration-test/csit/suites/integration/basic &&
robot -L debug \
--variable USER_HOME:/home/centos \
--variable DEFAULT_LINUX_PROMPT:\$ \
--variable ODL_SYSTEM_IP:opendaylight \
--variable ODL_SYSTEM_USER:centos \
./restconf_modules.robot'
- name: Log in to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Push Docker image
run: docker push ${{ vars.DOCKER_REPOSITORY }}/${{ vars.ROBOT_BASE_IMAGE_NAME }}
- name: Authenticate and push GHCR
uses: docker/login-action@v1
with:
registry: ${{ env.DOCKER_REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build the hello-docker Docker image
run: |
docker build . --tag ${{ env.DOCKER_REGISTRY }}/${{ vars.DOCKER_REPOSITORY }}/${{ vars.ROBOT_BASE_IMAGE_NAME }}:latest
docker run ${{ env.DOCKER_REGISTRY }}/${{ vars.DOCKER_REPOSITORY }}/${{ vars.ROBOT_BASE_IMAGE_NAME }}:latest
docker push ${{ env.DOCKER_REGISTRY }}/${{ vars.DOCKER_REPOSITORY }}/${{ vars.ROBOT_BASE_IMAGE_NAME }}:latest