From 36db988f73725665824d890e738544901d77650f Mon Sep 17 00:00:00 2001 From: Madhu Rajanna Date: Tue, 8 Jun 2021 11:23:35 +0530 Subject: [PATCH] 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 --- .github/workflows/publish-artifacts.yaml | 35 +++++++ .mergify.yml | 5 - .travis.yml | 32 ------ README.md | 2 - deploy.sh | 121 +++++++++++------------ docs/releases.md | 7 +- scripts/travis-functest.sh | 5 +- scripts/travis-helmtest.sh | 5 +- 8 files changed, 99 insertions(+), 113 deletions(-) create mode 100644 .github/workflows/publish-artifacts.yaml delete mode 100644 .travis.yml diff --git a/.github/workflows/publish-artifacts.yaml b/.github/workflows/publish-artifacts.yaml new file mode 100644 index 000000000..882057be0 --- /dev/null +++ b/.github/workflows/publish-artifacts.yaml @@ -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 diff --git a/.mergify.yml b/.mergify.yml index a31b68375..bd969b7c7 100644 --- a/.mergify.yml +++ b/.mergify.yml @@ -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" diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index d24fd69d7..000000000 --- a/.travis.yml +++ /dev/null @@ -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 diff --git a/README.md b/README.md index ea0ccb98d..ac530b377 100644 --- a/README.md +++ b/README.md @@ -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) diff --git a/deploy.sh b/deploy.sh index f83c28249..cce32ee6e 100755 --- a/deploy.sh +++ b/deploy.sh @@ -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,41 +52,64 @@ 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 -fi +push_helm_charts() { + PACKAGE=$1 + CHARTDIR=$2 + VERSION=${CSI_IMAGE_VERSION//v/} # Set version (without v prefix) -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 + # 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" - "${CONTAINER_CMD:-docker}" login -u "${QUAY_IO_USERNAME}" -p "${QUAY_IO_PASSWORD}" quay.io + 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" - set -xe + fi + fi - build_push_images - - CSI_CHARTS_DIR=$(mktemp -d) - - pushd "$CSI_CHARTS_DIR" >/dev/null - - curl -L https://git.io/get_helm.sh | bash -s -- --version "${HELM_VERSION}" - - build_step "cloning ceph/csi-charts repository" - git clone https://github.com/ceph/csi-charts - - mkdir -p csi-charts/docs + 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 - build_step "pushing RBD helm charts" - push_helm_charts rbd "$CSI_CHARTS_DIR" - build_step "pushing CephFS helm charts" - push_helm_charts cephfs "$CSI_CHARTS_DIR" - build_step_log "finished deployment!" + 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 - [ -n "${CSI_CHARTS_DIR}" ] && rm -rf "${CSI_CHARTS_DIR}" +} + +if [[ -z "${GITHUB_TOKEN}" ]]; then + echo "GITHUB_TOKEN is unset or set to the empty string" + exit 1 fi + +build_push_images + +CSI_CHARTS_DIR=$(mktemp -d) + +pushd "$CSI_CHARTS_DIR" >/dev/null + +curl -L https://git.io/get_helm.sh | bash -s -- --version "${HELM_VERSION}" + +build_step "cloning ceph/csi-charts repository" +git clone https://github.com/ceph/csi-charts + +mkdir -p csi-charts/docs +popd >/dev/null + +build_step "pushing RBD helm charts" +push_helm_charts rbd "$CSI_CHARTS_DIR" +build_step "pushing CephFS helm charts" +push_helm_charts cephfs "$CSI_CHARTS_DIR" +build_step_log "finished deployment!" + +[ -n "${CSI_CHARTS_DIR}" ] && rm -rf "${CSI_CHARTS_DIR}" diff --git a/docs/releases.md b/docs/releases.md index 44b7786cd..2c08b98ff 100644 --- a/docs/releases.md +++ b/docs/releases.md @@ -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. - diff --git a/scripts/travis-functest.sh b/scripts/travis-functest.sh index 64500e133..44649acab 100755 --- a/scripts/travis-functest.sh +++ b/scripts/travis-functest.sh @@ -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 @@ -15,7 +15,7 @@ kube_version() { # configure global environment variables # shellcheck source=build.env source "$(dirname "${0}")/../build.env" -cat << EOF | sudo tee -a /etc/environment +cat <