Skip to content

Commit

Permalink
CI: Push docker image to GHCR
Browse files Browse the repository at this point in the history
Signed-off-by: Anil Belur <abelur@linuxfoundation.org>
  • Loading branch information
askb committed Sep 14, 2023
1 parent afa448d commit 4e8b956
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 13 deletions.
43 changes: 38 additions & 5 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
name: Build and Run Docker Image
---
name: Build Ubuntu/CentOS Docker Image and Push them to Docker registry

on:
push:
Expand All @@ -8,10 +9,12 @@ on:
inputs:
OS_FLAVOR:
description: "Linux Flavor"
required: false
required: true
type: string
default: ubuntu

env:
DOCKER_REGISTRY: "ghcr.io"

jobs:
builder-docker-image:
Expand All @@ -21,11 +24,12 @@ jobs:
uses: actions/checkout@v3

- name: Build Ubuntu Docker image
run: docker build -t ${{ vars.DOCKER_REPOSITORY }}/${{ vars.ODL_BASE_IMAGE_NAME }} builder/${{ vars.OS_FLAVOR }}
# 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
run: |
docker run ${{ vars.DOCKER_REPOSITORY }}/${{ vars.ODL_BASE_IMAGE_NAME }} \
# 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'

Expand All @@ -36,8 +40,23 @@ jobs:
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:
Expand Down Expand Up @@ -68,6 +87,7 @@ jobs:
--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:
Expand All @@ -76,3 +96,16 @@ jobs:

- 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
10 changes: 6 additions & 4 deletions .github/workflows/csit-1-node.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
---
name: CSIT-1-Node-Test

on:
push:
# Trigger the workflow on a push event
branches:
- main

jobs:
csit:
Expand Down Expand Up @@ -74,11 +76,11 @@ jobs:
elif [ "${{ matrix.test_suite }}" == "distribution" ]; then
robot_test_file="karaf_sequence_install.robot karaf_stop.robot size.robot"
elif [ "${{ matrix.test_suite }}" == "aaa" ]; then
robot_test_file="authn"
robot_test_file="authn"
fi
# Run robot tests in the appropriate directory
docker exec robot bash -c "git clone https://github.com/opendaylight/integration-test.git &&
cd integration-test/csit/suites/${test_suite} &&
docker exec robot bash -c "git clone https://github.com/opendaylight/integration-test.git &&
cd integration-test/csit/suites/${test_suite} &&
robot -L debug --variable USER_HOME:/root \
--variable WORKSPACE:/home/youruser \
-v BUNDLEFOLDER:karaf-0.18.1 \
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/maven-build.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
name: Build and Run Docker Image

on:
Expand Down
4 changes: 2 additions & 2 deletions builder/centos/dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ RUN yum install -y java-17-openjdk java-17-openjdk-devel
# Download and install Maven 3.8
RUN wget -q https://downloads.apache.org/maven/maven-3/3.8.8/binaries/apache-maven-3.8.8-bin.tar.gz && \
tar -xf apache-maven-3.8.8-bin.tar.gz -C /opt && \
rm apache-maven-3.8.8-bin.tar.gz
rm apache-maven-3.8.8-bin.tar.gz

# Set environment variables
ENV MAVEN_HOME=/opt/apache-maven-3.8.8
Expand All @@ -30,4 +30,4 @@ RUN java -version && \
# Add Maven settings.xml file
RUN mkdir -p /root/.m2 \
&& wget -q -O /tmp/settings.xml https://raw.githubusercontent.com/opendaylight/odlparent/master/settings.xml \
&& mv /tmp/settings.xml /root/.m2/settings.xml
&& mv /tmp/settings.xml /root/.m2/settings.xml
4 changes: 2 additions & 2 deletions builder/ubuntu/dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ RUN apt-get install openjdk-17-jdk openjdk-17-jre -y
# Download and install Maven 3.8
RUN wget -q https://downloads.apache.org/maven/maven-3/3.8.8/binaries/apache-maven-3.8.8-bin.tar.gz && \
tar -xf apache-maven-3.8.8-bin.tar.gz -C /opt && \
rm apache-maven-3.8.8-bin.tar.gz
rm apache-maven-3.8.8-bin.tar.gz

# Set environment variables
ENV MAVEN_HOME=/opt/apache-maven-3.8.8
Expand All @@ -25,4 +25,4 @@ RUN java -version && \
# Add Maven settings.xml file
RUN mkdir -p /root/.m2 \
&& wget -q -O /tmp/settings.xml https://raw.githubusercontent.com/opendaylight/odlparent/master/settings.xml \
&& mv /tmp/settings.xml /root/.m2/settings.xml
&& mv /tmp/settings.xml /root/.m2/settings.xml

0 comments on commit 4e8b956

Please sign in to comment.