Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shared Docker image build logic with other products #111

Merged
merged 1 commit into from
Nov 24, 2022
Merged
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
69 changes: 36 additions & 33 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

#
# CHMPX
#
Expand Down Expand Up @@ -64,9 +65,9 @@ jobs:
# is created, including the OS that will end support soon.
# The new version will support the following OS, and these OS list
# will replace current matrix.
# ubuntu:jammy
# ubuntu:focal
# ubuntu:bionic
# ubuntu:22.04
# ubuntu:20.04
# ubuntu:18.04
# debian:bullseye
# debian:buster
# centos:centos7
Expand Down Expand Up @@ -172,27 +173,12 @@ jobs:
#
# Run building and pushing helper
#
# [NOTE] Secrets and Environments
# When passing parameters to docker_helper.sh in build and pusing,
# use Secret of organization or repository.
#
# By setting the correct values for the following variable names,
# they will be passed as parameters in docker_helper.sh.
# * DOCKER_HUB_USERNAME : Docker Hub username to read/push the docker images
# * DOCKER_HUB_ACCESSTOKEN : Docker Hub user's Access Token
# DOCKER_HUB_ORG : Docker Hub organization to push(ex. "antpickax")
# IMAGETYPE_VARS_FILE : specify custom variables file
# FORCE_DOCKER_PUSH : specify force push(true) or not push(false)
#
# [REQUIRED]
# DOCKER_HUB_USERNAME and DOCKER_HUB_ACCESSTOKEN is required to read and push docker images!
#
steps:
- name: Checkout sources
uses: actions/checkout@v1
uses: actions/checkout@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
uses: docker/setup-buildx-action@v2

#
# Login to avoid the Docker Hub rate limit
Expand All @@ -211,21 +197,38 @@ jobs:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESSTOKEN }}

- name: Build and Push to Docker Hub
env:
TMP_CI_DOCKER_IMAGE_INFO: ${{ matrix.imageinfo }}
TMP_CI_DOCKER_IMAGE_NAMES: "chmpx,chmpx-dev"
TMP_CI_IMAGETYPE_VARS_FILE: ${{ secrets.IMAGETYPE_VARS_FILE }}
TMP_CI_DOCKER_HUB_ORG: ${{ secrets.DOCKER_HUB_ORG }}
TMP_CI_FORCE_DOCKER_PUSH: ${{ secrets.FORCE_DOCKER_PUSH }}
#
# Set environments from secrets
#
# [NOTE] Secrets
# When passing parameters to docker_helper.sh in build and pusing,
# use Secret of organization or repository.
#
# By setting the correct values for the following variable names,
# they will be passed as parameters in docker_helper.sh.
# * DOCKER_HUB_USERNAME : Docker Hub username to read/push the docker images
# * DOCKER_HUB_ACCESSTOKEN : Docker Hub user's Access Token
# DOCKER_HUB_ORG : Docker Hub organization to push(ex. "antpickax")
# IMAGETYPE_VARS_FILE : specify custom variables file
# FORCE_DOCKER_PUSH : specify force push(true) or not push(false)
#
# [REQUIRED]
# DOCKER_HUB_USERNAME and DOCKER_HUB_ACCESSTOKEN is required to read and push docker images!
#
- name: Set docker image build environments from secrets
run: |
echo "ENV_DOCKER_IMAGE_INFO=${{ matrix.imageinfo }}" >> "${GITHUB_ENV}"
echo "ENV_IMAGE_NAMES=chmpx,chmpx-dev" >> "${GITHUB_ENV}"
echo "ENV_IMAGEVAR_FILE=${{ secrets.IMAGETYPE_VARS_FILE }}" >> "${GITHUB_ENV}"
echo "ENV_DOCKER_HUB_ORG=${{ secrets.DOCKER_HUB_ORG }}" >> "${GITHUB_ENV}"
echo "ENV_FORCE_PUSH=${{ secrets.FORCE_DOCKER_PUSH }}" >> "${GITHUB_ENV}"

#
# Run building and pushing
#
- name: Build and Push image to Docker Hub
run: |
OPT_CI_DOCKER_IMAGE_INFO="-i ${TMP_CI_DOCKER_IMAGE_INFO}";
OPT_CI_DOCKER_IMAGE_NAMES="-n ${TMP_CI_DOCKER_IMAGE_NAMES}"
if [ "X${TMP_CI_IMAGETYPE_VARS_FILE}" != "X" ]; then OPT_CI_IMAGETYPE_VARS_FILE="-f ${TMP_CI_IMAGETYPE_VARS_FILE}"; fi
if [ "X${TMP_CI_DOCKER_HUB_ORG}" != "X" ]; then OPT_CI_DOCKER_HUB_ORG="-o ${TMP_CI_DOCKER_HUB_ORG}"; fi
if [ "X${TMP_CI_FORCE_DOCKER_PUSH}" = "Xtrue" ]; then OPT_CI_FORCE_DOCKER_PUSH="-p"; elif [ "X${TMP_CI_FORCE_DOCKER_PUSH}" = "Xfalse" ]; then OPT_CI_FORCE_DOCKER_PUSH="-np"; fi
/bin/sh -c "${GITHUB_WORKSPACE}/.github/workflows/docker_helper.sh ${OPT_CI_DOCKER_IMAGE_INFO} ${OPT_CI_DOCKER_HUB_ORG} ${OPT_CI_DOCKER_IMAGE_NAMES} ${OPT_CI_FORCE_DOCKER_PUSH}"
${GITHUB_WORKSPACE}/.github/workflows/docker_helper.sh

#
# Local variables:
Expand Down
Loading