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

Fix the Travis, add Circle CI project deployment #5095

Merged
merged 1 commit into from
Jun 27, 2019
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
4 changes: 2 additions & 2 deletions geoportal/c2cgeoportal_geoportal/scaffolds/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ def post(self, command, output_dir, vars_):
Overrides the base template class to print the next step.
"""

fix_executables(output_dir, ("bin/*", "build"))
fix_executables(output_dir, ("bin/*", "build", "scripts/publish-docker"))

return BaseTemplate.post(self, command, output_dir, vars_)

Expand Down Expand Up @@ -202,6 +202,6 @@ def post(self, command, output_dir, vars_):
after a successful scaffolding rendering.
"""

fix_executables(output_dir, ("bin/*", "build"), True)
fix_executables(output_dir, ("bin/*", "build", "scripts/publish-docker"), True)

return BaseTemplate.post(self, command, output_dir, vars_)
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ addons:
env:
global:
- PROJECT={{package}}
- TAG=int
# - OPENSHIFT_PROJECT=gs-gmf-{{package}}
# - HELM_RELEASE_NAMES=List of branch that should be deployed on helm
# - DOCKER_USERNAME=username
Expand All @@ -23,12 +22,16 @@ jobs:
include:
- stage: config-geoportal
script:
- docker build --tag=camptocamp/{{package}}-config:${TAG} \
--build-arg=PGSCHEMA=main .
after_success:
- scripts/publish-docker config
- ./build --config
deploy:
- provider: script
script: scripts/publish-docker config
on:
all_branches: true
- script:
- docker build --tag=camptocamp/{{package}}-geoportal:${TAG} \
--build-arg=GIT_HASH=$(git rev-parse HEAD) geoportal
after_success:
- scripts/publish-docker geoportal
- ./build --geoportal
deploy:
- provider: script
script: scripts/publish-docker geoportal
on:
all_branches: true
40 changes: 30 additions & 10 deletions geoportal/c2cgeoportal_geoportal/scaffolds/create/build_tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,43 @@ function help {
echo Usage:
echo './build -> keep the curent .env if exists or use the .env.sample'
echo './build [env files...] -> use the ordered env files list'
exit 1
exit 0
}

if [ $# -gt 0 ] && ( [ $1 == '-h' ] || [ $1 == '--help' ] )
then
help
fi

set -x
docker build --tag=camptocamp/{{package}}-config \
--build-arg=PGSCHEMA=main .
docker build --target=builder --tag=camptocamp/{{package}}-geoportal-dev \
--build-arg=PGSCHEMA=main \
--build-arg=GIT_HASH=$(git rev-parse HEAD) geoportal
docker build --tag=camptocamp/{{package}}-geoportal \
--build-arg=PGSCHEMA=main \
--build-arg=GIT_HASH=$(git rev-parse HEAD) geoportal
CONFIG=true
GEOPORTAL=true
if [ $1 == '--config' ]
then
GEOPORTAL=false
shift
fi
if [ $1 == '--geoportal' ]
then
CONFIG=false
shift
fi

if [ $CONFIG == true ]
then
set -x
docker build --tag=camptocamp/{{package}}-config \
--build-arg=PGSCHEMA=main .
fi
if [ $GEOPORTAL == true ]
then
set -x
docker build --target=builder --tag=camptocamp/{{package}}-geoportal-dev \
--build-arg=PGSCHEMA=main \
--build-arg=GIT_HASH=$(git rev-parse HEAD) geoportal
docker build --tag=camptocamp/{{package}}-geoportal \
--build-arg=PGSCHEMA=main \
--build-arg=GIT_HASH=$(git rev-parse HEAD) geoportal
fi

if [ $# -gt 0 ]
then
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import os.path
import sys
import subprocess

if os.environ['TRAVIS_PULL_REQUEST'] == 'true':
if os.environ.get('TRAVIS_PULL_REQUEST', 'false') == 'true':
print('Not deploying images for pull requests')
exit(0)

version = os.environ['TRAVIS_BRANCH']
version = os.environ.get('CIRCLE_BRANCH', os.environ.get('TRAVIS_BRANCH'))

if version not in os.environ.get('HELM_RELEASE_NAMES', '').split(','):
print('Not a release branch')
Expand All @@ -22,7 +22,7 @@ subprocess.check_call([
'--password=' + os.environ['DOCKER_PASSWORD'],
])

images = sys.args[1:]
images = sys.argv[1:]
for image in images:
full_image = 'camptocamp/{}-{}'.format(os.environ['PROJECT'], image)
src_image = full_image
Expand All @@ -42,18 +42,16 @@ openshift_url = 'https://github.com/openshift/origin/releases/download/v{}/{}'.f
)
subprocess.check_call(['wget', '--quiet', openshift_url], cwd='/tmp')
subprocess.check_call(['tar', 'xfz', openshift_file], cwd='/tmp')
subprocess.check_call([
'mv', '{}/oc'.format(openshift_version_name), os.path.expanduser('~/bin/')
], cwd='/tmp')
oc = '/tmp/{}/oc'.format(openshift_version_name)

subprocess.check_call([
'oc', 'login', os.environ['OPENSHIFT_URL'],
subprocess.check_output([
oc, 'login', os.environ['OPENSHIFT_URL'],
'--username=' + os.environ['OPENSHIFT_USERNAME'],
'--password=' + os.environ['OPENSHIFT_PASSWORD'],
])
subprocess.check_call(['oc', 'project', os.environ['OPENSHIFT_PROJECT']])
subprocess.check_call([oc, 'project', os.environ['OPENSHIFT_PROJECT']])
for image in images:
openshift_image_ref = '{}-c2cgeoportal-{}:{}'.format(version, image, version)
subprocess.check_call([
'oc', 'import-image', openshift_image_ref, '--scheduled=true', '--reference-policy=local',
oc, 'import-image', openshift_image_ref, '--scheduled=true', '--reference-policy=local',
])