ci: pushing artifacts using github actions

As Travis CI `https://travis-ci.org/` is getting
shutdown date on June 15th. Either we need to move
to new place https://www.travis-ci.com/ or we can
switch to github action to push image and the helm
charts when a PR is merged.

fixes: #1781

Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
This commit is contained in:
Madhu Rajanna 2021-06-08 11:23:35 +05:30
parent 7b5c78ec7c
commit c70e46a77c
8 changed files with 99 additions and 113 deletions

View File

@ -0,0 +1,35 @@
---
name: publish artifacts
# yamllint disable-line rule:truthy
on:
push:
# Sequence of patterns matched against refs/heads
branches:
# Push events on default branch
- devel
# Push events to branches matching refs/heads/release-v*
- 'release-v*'
jobs:
push:
name: Publish artifacts
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Login to Quay
uses: docker/login-action@v1
with:
registry: quay.io
username: ${{ secrets.QUAY_IO_USERNAME }}
password: ${{ secrets.QUAY_IO_PASSWORD }}
- name: Set build environment based on Git branch name
if: github.ref == 'refs/heads/devel'
run: echo "BRANCH_NAME=devel" >> $GITHUB_ENV
- name: publish artifacts
# podman cannot pull images with both tag and digest
# https://github.com/containers/buildah/issues/1407
# use docker to build images
# yamllint disable-line rule:line-length
run: GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }} CONTAINER_CMD=docker ./deploy.sh

View File

@ -99,7 +99,6 @@ pull_request_rules:
- label!=DNM
- "#changes-requested-reviews-by=0"
- "#approved-reviews-by>=1"
- "status-success=continuous-integration/travis-ci/pr"
actions:
merge: {}
dismiss_reviews: {}
@ -120,7 +119,6 @@ pull_request_rules:
- label!=DNM
- "#changes-requested-reviews-by=0"
- "#approved-reviews-by>=1"
- "status-success=continuous-integration/travis-ci/pr"
actions:
merge: {}
dismiss_reviews: {}
@ -141,7 +139,6 @@ pull_request_rules:
- label!=DNM
- "#changes-requested-reviews-by=0"
- "#approved-reviews-by>=1"
- "status-success=continuous-integration/travis-ci/pr"
actions:
merge: {}
dismiss_reviews: {}
@ -162,7 +159,6 @@ pull_request_rules:
- label!=DNM
- "#changes-requested-reviews-by=0"
- "#approved-reviews-by>=1"
- "status-success=continuous-integration/travis-ci/pr"
actions:
merge: {}
dismiss_reviews: {}
@ -184,7 +180,6 @@ pull_request_rules:
- "#changes-requested-reviews-by=0"
- "#approved-reviews-by>=1"
- "status-success=multi-arch-build"
- "status-success=continuous-integration/travis-ci/pr"
- "status-success=ci/centos/mini-e2e-helm/k8s-1.19"
- "status-success=ci/centos/mini-e2e-helm/k8s-1.20"
- "status-success=ci/centos/mini-e2e/k8s-1.19"

View File

@ -1,32 +0,0 @@
---
# need for docker build
os: linux
dist: bionic
addons:
apt:
packages:
- coreutils
- ruby
- socat
services:
- docker
language: go
branches:
only:
- devel
# Only run the deploy stage on push (not pull_request) events.
stages:
- name: deploy
if: type = push
jobs:
include:
- stage: deploy
name: push artifacts to repositories
install:
- export HELM_VERSION=$(source build.env ; echo ${HELM_VERSION})
- curl -L https://git.io/get_helm.sh
| bash -s -- -v "${HELM_VERSION}"
script: ./deploy.sh

View File

@ -2,8 +2,6 @@
[![Go Report
Card](https://goreportcard.com/badge/github.com/ceph/ceph-csi)](https://goreportcard.com/report/github.com/ceph/ceph-csi)
[![Build
Status](https://travis-ci.org/ceph/ceph-csi.svg?branch=devel)](https://travis-ci.org/ceph/ceph-csi)
- [Ceph CSI](#ceph-csi)
- [Overview](#overview)

View File

@ -1,43 +1,13 @@
#!/bin/bash
set -e
# shellcheck source=scripts/build_step.inc.sh
source "$(dirname "${0}")/scripts/build_step.inc.sh"
source "$(dirname "${0}")/build.env"
push_helm_charts() {
PACKAGE=$1
CHARTDIR=$2
VERSION=${CSI_IMAGE_VERSION//v/} # Set version (without v prefix)
# update information in Chart.yaml if the branch is not devel
if [ "$TRAVIS_BRANCH" != "devel" ]; then
# Replace appVersion: canary and version: *-canary with the actual version
sed -i "s/\(\s.*canary\)/ $VERSION/" "charts/ceph-csi-$PACKAGE/Chart.yaml"
if [[ "$VERSION" == *"canary"* ]]; then
# Replace devel with the version branch
sed -i "s/devel/$TRAVIS_BRANCH/" "charts/ceph-csi-$PACKAGE/Chart.yaml"
else
# This is not a canary release, replace devel with the tagged branch
sed -i "s/devel/v$VERSION/" "charts/ceph-csi-$PACKAGE/templates/NOTES.txt"
sed -i "s/devel/v$VERSION/" "charts/ceph-csi-$PACKAGE/Chart.yaml"
fi
fi
mkdir -p "$CHARTDIR/csi-charts/docs/$PACKAGE"
cp -R "./charts/ceph-csi-$PACKAGE" "$CHARTDIR/csi-charts/docs/$PACKAGE"
pushd "$CHARTDIR/csi-charts/docs/$PACKAGE" >/dev/null
helm package "ceph-csi-$PACKAGE"
popd >/dev/null
pushd "$CHARTDIR/csi-charts/docs" >/dev/null
helm repo index .
git add --all :/ && git commit -m "Update for helm charts $PACKAGE-$VERSION"
git push https://"$GITHUB_TOKEN"@github.com/ceph/csi-charts
popd >/dev/null
}
BRANCH_NAME=${BRANCH_NAME:-""}
GITHUB_TOKEN=${GITHUB_TOKEN:-""}
# Build and push images. Steps as below:
# 1. get base image from ./build.env (BASE_IMAGE=ceph/ceph:v14.2)
@ -82,21 +52,45 @@ build_push_images() {
make push-manifest
}
if [ "${TRAVIS_BRANCH}" != 'devel' ]; then
echo "!!! Branch ${TRAVIS_BRANCH} is not a deployable branch; exiting"
exit 0 # Exiting 0 so that this isn't marked as failing
push_helm_charts() {
PACKAGE=$1
CHARTDIR=$2
VERSION=${CSI_IMAGE_VERSION//v/} # Set version (without v prefix)
# update information in Chart.yaml if the branch is not devel
if [ "${BRANCH_NAME}" != "devel" ]; then
# Replace appVersion: canary and version: *-canary with the actual version
sed -i "s/\(\s.*canary\)/ $VERSION/" "charts/ceph-csi-$PACKAGE/Chart.yaml"
if [[ "$VERSION" == *"canary"* ]]; then
# Replace devel with the version branch
sed -i "s/devel/$BRANCH_NAME/" "charts/ceph-csi-$PACKAGE/Chart.yaml"
else
# This is not a canary release, replace devel with the tagged branch
sed -i "s/devel/v$VERSION/" "charts/ceph-csi-$PACKAGE/templates/NOTES.txt"
sed -i "s/devel/v$VERSION/" "charts/ceph-csi-$PACKAGE/Chart.yaml"
fi
fi
if [ "${TRAVIS_PULL_REQUEST}" == "false" ]; then
build_step "log in to quay.io as user ${QUAY_IO_USERNAME}"
# This is a workaround to fix docker permission denied issue during manifest create in Travis CI.
# `docker manifest create` fails due to permission denied on `/etc/docker/certs.d/quay.io`
# (https://github.com/docker/for-linux/issues/396).
sudo chmod o+x /etc/docker
mkdir -p "$CHARTDIR/csi-charts/docs/$PACKAGE"
cp -R "./charts/ceph-csi-$PACKAGE" "$CHARTDIR/csi-charts/docs/$PACKAGE"
pushd "$CHARTDIR/csi-charts/docs/$PACKAGE" >/dev/null
helm package "ceph-csi-$PACKAGE"
popd >/dev/null
"${CONTAINER_CMD:-docker}" login -u "${QUAY_IO_USERNAME}" -p "${QUAY_IO_PASSWORD}" quay.io
pushd "$CHARTDIR/csi-charts/docs" >/dev/null
helm repo index .
git add --all :/ && git commit -m "Update for helm charts $PACKAGE-$VERSION"
git push https://"$GITHUB_TOKEN"@github.com/ceph/csi-charts
popd >/dev/null
set -xe
}
if [[ -z "${GITHUB_TOKEN}" ]]; then
echo "GITHUB_TOKEN is unset or set to the empty string"
exit 1
fi
build_push_images
@ -119,4 +113,3 @@ if [ "${TRAVIS_PULL_REQUEST}" == "false" ]; then
build_step_log "finished deployment!"
[ -n "${CSI_CHARTS_DIR}" ] && rm -rf "${CSI_CHARTS_DIR}"
fi

View File

@ -4,7 +4,7 @@
- [Introduction](#introduction)
- [Versioning](#versioning)
- [Tagging repositories](#tagging-repositories)
- [Release process](#release-process-tbd)
- [Release process [TBD]](#release-process-tbd)
## Introduction
@ -47,8 +47,8 @@ and it must be backward compatible.
The tag name must begin with "v" followed by the version number, conforming to
the [versioning](#versioning) requirements (e.g. a tag of `v1.0.0-rc2` for
version `1.0.0-rc2`). This tag format is used by the Travis CI infrastructure to
properly upload and tag releases to Quay and Docker Hub.
version `1.0.0-rc2`). This tag format is used by the GitHub action
infrastructure to properly upload and tag releases to Quay.
## Release process [TBD]
@ -74,4 +74,3 @@ of each release:
2.1.0) can be linked to issues and PRs for better tracking release items.
- Once all steps are complete, close the issue and the milestone.

View File

@ -1,7 +1,7 @@
#!/bin/bash
set -e
# This script will be used by travis to run functional test
# This script will be used by centos CI to run functional test
# against different Kubernetes version
export KUBE_VERSION=$1
shift
@ -27,7 +27,6 @@ sudo scripts/minikube.sh create-block-pool
# pull docker images to speed up e2e
sudo scripts/minikube.sh cephcsi
sudo scripts/minikube.sh k8s-sidecar
sudo chown -R travis: "$HOME"/.minikube /usr/local/bin/kubectl
KUBE_MAJOR=$(kube_version 1)
KUBE_MINOR=$(kube_version 2)
# skip snapshot operation if kube version is less than 1.17.0

View File

@ -1,7 +1,7 @@
#!/bin/bash
set -e
# This script will be used by travis to run functional test
# This script will be used by centos CI to run functional test
# against different Kubernetes version
export KUBE_VERSION=$1
shift
@ -31,7 +31,6 @@ sudo scripts/minikube.sh create-block-pool
# pull docker images to speed up e2e
sudo scripts/minikube.sh cephcsi
sudo scripts/minikube.sh k8s-sidecar
sudo chown -R travis: "$HOME"/.minikube /usr/local/bin/kubectl
NAMESPACE=cephcsi-e2e-$RANDOM
# create ns for e2e