-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
use tagging instead of staging branch
- Loading branch information
Showing
21 changed files
with
497 additions
and
571 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
name: Github-CI-Hotfix-Release | ||
|
||
on: | ||
push: | ||
tags: | ||
- v[0-9]+.[0-9]+.[0-9]+ | ||
|
||
env: | ||
# secrets can be set in settings/secrets on github | ||
DOCKER_REGISTRY: ${{ secrets.DOCKER_REGISTRY }} | ||
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} | ||
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} | ||
|
||
jobs: | ||
deploy: | ||
if: contains(github.event.base_ref, 'refs/heads/hotfix_v') | ||
# only run on staging branch | ||
name: deploy release | ||
runs-on: ubuntu-latest | ||
env: | ||
FROM_TAG_PREFIX: hotfix-github | ||
TO_TAG_PREFIX: release-github | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: setup docker | ||
run: | | ||
sudo ./ci/github/helpers/setup_docker_compose.bash | ||
./ci/github/helpers/setup_docker_experimental.bash | ||
./ci/github/helpers/setup_docker_buildx.bash | ||
echo ::set-env name=DOCKER_BUILDX::1 | ||
- name: set owner variable | ||
run: echo ::set-env name=OWNER::${GITHUB_REPOSITORY%/*} | ||
- name: set git tag | ||
run: echo ::set-env name=GIT_TAG::${GITHUB_REF##*/} | ||
- name: deploy | ||
run: ./ci/deploy/dockerhub-tag-version.bash |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
name: Github-CI-Staging | ||
|
||
on: | ||
push: | ||
tags: | ||
- staging_[a-zA-Z]+[0-9]+ | ||
|
||
env: | ||
# secrets can be set in settings/secrets on github | ||
DOCKER_REGISTRY: ${{ secrets.DOCKER_REGISTRY }} | ||
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} | ||
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} | ||
|
||
jobs: | ||
deploy: | ||
if: github.event.base_ref == 'refs/heads/master' | ||
name: deploy staging | ||
runs-on: ubuntu-latest | ||
env: | ||
FROM_TAG_PREFIX: master-github | ||
TO_TAG_PREFIX: staging-github | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: setup docker | ||
run: | | ||
sudo ./ci/github/helpers/setup_docker_compose.bash | ||
./ci/github/helpers/setup_docker_experimental.bash | ||
./ci/github/helpers/setup_docker_buildx.bash | ||
echo ::set-env name=DOCKER_BUILDX::1 | ||
- name: set owner variable | ||
run: echo ::set-env name=OWNER::${GITHUB_REPOSITORY%/*} | ||
- name: set git tag | ||
run: echo ::set-env name=GIT_TAG::${GITHUB_REF##*/} | ||
- name: deploy | ||
run: ./ci/deploy/dockerhub-tag-version.bash |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,20 @@ | ||
# Continuous Integration | ||
|
||
## Travis / Dockerhub setup | ||
## CI / Dockerhub setup | ||
|
||
The osparc-simcore repository provides a Travis-CI [recipe](.travis.yml) that fullfills the [Release Workflow](docs/img/git-release-workflow.svg). | ||
The osparc-simcore repository provides a Travis-CI [recipe](.travis.yml) and Gihub-CI [workflows](.github/workflows) that fullfills the [Release Workflow](docs/img/git-release-workflow.svg) and the [Hotfix Workflow](docs/img/git-hotfix-workflow.svg). | ||
|
||
To this end Travis should be enabled for the repository in each fork and a [Dockerhub](https://hub.docker.com/) account is recommended to push the docker images generated by Travis. | ||
### Configuration | ||
Github Actions and/or Travis-CI should be enabled for the repository in each fork and a [Dockerhub](https://hub.docker.com/) account is recommended to push the docker images generated by the CI. | ||
|
||
Configuring your travis settings will speed up the travis CI process by making use of Dockerhub (or another docker registry) to move docker images between stages. | ||
Configuring your CI settings will speed up the CI process by making use of Dockerhub (or another docker registry) to move docker images between stages. | ||
|
||
### Travis configuration | ||
### Secrets configuration | ||
|
||
Define the following secure environment variables in your fork: | ||
|
||
```bash | ||
DOCKER_REGISTRY # this shall be set to your own dockerhub repository account for example: itisfoundation | ||
DOCKER_USERNAME # the docker username (!beware this should be a [secure env variable](https://docs.travis-ci.com/user/environment-variables/#defining-encrypted-variables-in-travisyml)) | ||
DOCKER_PASSWORD # the docker password (!beware this should be a [secure env variable](https://docs.travis-ci.com/user/environment-variables/#defining-encrypted-variables-in-travisyml)) | ||
DOCKER_USERNAME # the docker username | ||
DOCKER_PASSWORD # the docker password | ||
``` | ||
|
||
### Release workflow | ||
|
||
![Git release workflow](../docs/img/git-release-workflow.svg) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,40 @@ | ||
#!/bin/bash | ||
# http://redsymbol.net/articles/unofficial-bash-strict-mode/ | ||
set -euo pipefail | ||
#!/usr/bin/env bash | ||
# strict mode | ||
set -o errexit # abort on nonzero exitstatus | ||
set -o nounset # abort on unbound variable | ||
set -o pipefail # don't hide errors within pipes | ||
IFS=$'\n\t' | ||
|
||
bash ci/helpers/dockerhub_login.bash | ||
my_dir="$(dirname "$0")" | ||
source "$my_dir/../../scripts/helpers/logger.bash" | ||
|
||
# check script needed variables | ||
if [ ! -v TAG_PREFIX ]; then | ||
echo "## ERROR: incorrect use of script. TAG_PREFIX (e.g. master, staging) not defined!" | ||
exit 1 | ||
error_exit "$LINENO" "incorrect use of script. TAG_PREFIX (e.g. master, staging) not defined!" | ||
fi | ||
|
||
log_info "logging in dockerhub..." | ||
bash ci/helpers/dockerhub_login.bash | ||
|
||
# pull the current tested build | ||
|
||
DOCKER_IMAGE_TAG=$(exec ci/helpers/build_docker_image_tag.bash) | ||
export DOCKER_IMAGE_TAG | ||
log_info "pulling build ${DOCKER_IMAGE_TAG}" | ||
make pull-version tag-local | ||
|
||
# show current images on system | ||
echo "## Before push" | ||
log_info "Before push" | ||
make info-images | ||
|
||
# re-tag build | ||
DOCKER_IMAGE_TAG="$TAG_PREFIX-latest" | ||
export DOCKER_IMAGE_TAG | ||
log_info "pushing images ${DOCKER_IMAGE_TAG} to ${DOCKER_REGISTRY}" | ||
make push-version | ||
|
||
# re-tag build to master-github-DATE.GIT_SHA | ||
DOCKER_IMAGE_TAG=$TAG_PREFIX-$(date --utc +"%Y-%m-%d--%H-%M").$(git rev-parse HEAD) | ||
export DOCKER_IMAGE_TAG | ||
log_info "pushing images ${DOCKER_IMAGE_TAG} to ${DOCKER_REGISTRY}" | ||
make push-version | ||
|
||
# show update of images on system | ||
echo "## After push" | ||
make info-images |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#!/usr/bin/env bash | ||
# strict mode | ||
set -o errexit # abort on nonzero exitstatus | ||
set -o nounset # abort on unbound variable | ||
set -o pipefail # don't hide errors within pipes | ||
IFS=$'\n\t' | ||
|
||
my_dir="$(dirname "$0")" | ||
source "$my_dir/../../scripts/helpers/logger.bash" | ||
|
||
# check script needed variables | ||
if [ ! -v FROM_TAG_PREFIX ] || [ ! -v TO_TAG_PREFIX ] || [ ! -v GIT_TAG ]; then | ||
error_exit "$LINENO" "incorrect use of script. FROM_TAG_PREFIX/TO_TAG_PREFIX (e.g. master, staging), and/or GIT_TAG not defined!" | ||
fi | ||
|
||
log_info "logging in dockerhub..." | ||
bash ci/helpers/dockerhub_login.bash | ||
|
||
log_info "finding the version in the docker hub registry..." | ||
# find and pull the tagged build | ||
# find the docker image tag | ||
export ORG=${DOCKER_REGISTRY} | ||
export REPO="webserver" | ||
# FROM_TAG_PREFIX-DATE.GIT_SHA | ||
export TAG_PATTERN="^${FROM_TAG_PREFIX}-.+\..+" | ||
DOCKER_IMAGE_TAG=$(./ci/helpers/find_docker_image_tag_from_git_sha.bash | awk 'END{print}') || exit $? | ||
log_info "found image ${DOCKER_IMAGE_TAG}" | ||
export DOCKER_IMAGE_TAG | ||
log_info "pulling images ${DOCKER_IMAGE_TAG} from ${DOCKER_REGISTRY}" | ||
make pull-version tag-local | ||
|
||
# show current images on system | ||
log_info "Before push" | ||
make info-images | ||
|
||
# re-tag images to ${TO_TAG_PREFIX}-{GIT_TAG}-DATE.GIT_SHA | ||
readonly GIT_COMMIT_SHA=$(git show-ref -s "${GIT_TAG}") | ||
DOCKER_IMAGE_TAG="${TO_TAG_PREFIX}-${GIT_TAG}"-$(date --utc +"%Y-%m-%d--%H-%M")."${GIT_COMMIT_SHA}" | ||
export DOCKER_IMAGE_TAG | ||
log_info "pushing images ${DOCKER_IMAGE_TAG} to ${DOCKER_REGISTRY}" | ||
make push-version | ||
|
||
# push latest image ${TO_TAG_PREFIX}-latest | ||
DOCKER_IMAGE_TAG="${TO_TAG_PREFIX}-latest" | ||
export DOCKER_IMAGE_TAG | ||
log_info "pushing images ${DOCKER_IMAGE_TAG} to ${DOCKER_REGISTRY}" | ||
make push-version | ||
|
||
log_info "complete!" |
Oops, something went wrong.