Skip to content

Commit

Permalink
Merge pull request #16 from hiwakaba/master
Browse files Browse the repository at this point in the history
Adds docker image
  • Loading branch information
hiwakaba authored Jan 13, 2023
2 parents 5d5c079 + fc6d6ea commit a17aa1c
Show file tree
Hide file tree
Showing 43 changed files with 3,061 additions and 70 deletions.
163 changes: 163 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,163 @@
#
# K2HR3 OpenStack Notification Listener
#
# Copyright 2018 Yahoo Japan Corporation
#
# K2HR3 is K2hdkc based Resource and Roles and policy Rules, gathers
# common management information for the cloud.
# K2HR3 can dynamically manage information as "who", "what", "operate".
# These are stored as roles, resources, policies in K2hdkc, and the
# client system can dynamically read and modify these information.
#
# For the full copyright and license information, please view
# the licenses file that was distributed with this source code.
#
# AUTHOR: Hirotaka Wakabayashi
# CREATE: Tue Sep 11 2018
# REVISION:
#
#

name: CI

on:
# Trigger the workflow on push or pull request,
# but only for the master branch
push:
branches: [ master,ci ]
pull_request:
branches: [ master ]
# Trigger the workflow on release,
# but only when published
release:
types:
- published
# Trigger the workflow on every Sunday midnight
schedule:
- cron: '0 0 * * 1'

jobs:
build:

if: "! contains(toJSON(github.event.commits.*.message), '[skip ci]') && ! contains(toJSON(github.event.commits.*.message), '[ci skip]')"
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.9', '3.10', '3.11']
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
ENV_FORCE_PUBLISHER: ${{ secrets.FORCE_PUBLISHER }}
ENV_USE_PACKAGECLOUD_REPO: ${{ secrets.USE_PACKAGECLOUD_REPO }}
ENV_PACKAGECLOUD_OWNER: ${{ secrets.PACKAGECLOUD_OWNER }}
ENV_PACKAGECLOUD_DOWNLOAD_REPO: ${{ secrets.PACKAGECLOUD_DOWNLOAD_REPO }}
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Run building and packaging
run: |
/bin/sh -c "$GITHUB_WORKSPACE/.github/workflows/python_helper.sh --pythontype ${{ matrix.python-version }}"
- name: Build and publish
if: github.event_name == 'release'
run: |
make release
dockerimage:
runs-on: ubuntu-latest

#
# build matrix for containers
#
strategy:
#
# do not stop jobs automatically if any of the jobs fail
#
fail-fast: false

#
# matrix for containers
#
matrix:
#
# Specify the "baseimage" in the following format:
# <base image tag>,<base dev image tag>,<OS tag name>(,<default tag flag>)
#
# <base image tag>: specify the Docker image name(ex. "alpine:latest")
# <base dev image tag>: specify the Docker image name(ex. "alpine:latest")
# <OS tag name>: OS tag attached to the created Docker image
# <default tag flag>: If you want to use the created Docker image as the default image, specify "default".
#
imageinfo:
- python:3.9-slim-buster,python:3.9-slim-buster,ubuntu
- alpine:latest,alpine:latest,alpine

#
# Run building and pushing helper
#
steps:
- name: Checkout sources
uses: actions/checkout@v3

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

#
# Login to avoid the Docker Hub rate limit
#
# Github Secret cannot be read in the case of Pull Request, so that process
# here will fail, so we need to skip it. Even if we skip this process, if we
# are using the official Runner of Github Actions, the IP address rate will
# not be limited and we will not get an error.
# However, this restriction release is based on the contract between Github
# and DockerHub, so if we skip this process, we may get an error.
#
- name: Login to DockerHub
if: ${{ github.event_name != 'pull_request' }}
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESSTOKEN }}

#
# 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=k2hr3-osnl" >> "${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: |
${GITHUB_WORKSPACE}/.github/workflows/docker_helper.sh
#
# Local variables:
# tab-width: 4
# c-basic-offset: 4
# End:
# vim600: expandtab sw=4 ts=4 fdm=marker
# vim<600: expandtab sw=4 ts=4
#
Loading

0 comments on commit a17aa1c

Please sign in to comment.