Skip to content

Commit

Permalink
Merge pull request #22 from ConductionNL/development
Browse files Browse the repository at this point in the history
Update from development branch
  • Loading branch information
rubenvdlinde authored Dec 3, 2019
2 parents 14fafab + 67bdc92 commit 96e00ff
Show file tree
Hide file tree
Showing 16 changed files with 1,275 additions and 1,114 deletions.
4 changes: 3 additions & 1 deletion .env
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ APP_VERSION=V.0.1
APP_DEBUG=1
# What is the enviroment type you want to use for local production? (choose between dec,stag,prod, acce or test)
APP_ENV=dev
# We use a build to tag images, this is swithced to the version on master and to env on other branches
APP_BUILD=dev
# The description for this api
APP_DESCRIPTION='This component provides a products and services catalogue that can be used by a order component in order to provide the products in the orders with better details. The design considerations are given in [DESIGN.md](https://github.com/ConductionNL/productenendienstencatalogus/blob/master/DESIGN.md) and [DESIGN-PDC.md](https://github.com/ConductionNL/productenendienstencatalogus/blob/master/DESIGN-PDC.md)'

Expand Down Expand Up @@ -50,7 +52,7 @@ NOTIFICATION_ENABLED_AUTHORIZATION=sasd
##################################################

AUTH_ENABLED=false
AUTH_PROVIDER=sasd
AUTH_PROVIDER=sasda
AUTH_AUTHORIZATION=sasd

##################################################
Expand Down
99 changes: 39 additions & 60 deletions .github/workflows/dockerimage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,86 +17,42 @@ jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v1
- name: Pulling old images, if any
run: docker-compose pull --ignore-pull-failures
- name: Setting APP_ENV
env:
APP_ENV: dev
run: echo "set APP_ENV to $APP_ENV"
- if: contains( github.ref, 'master' ) || contains( github.base_ref, 'master' )
env:
APP_ENV: prod
run: echo "set APP_ENV to $APP_ENV"
- if: contains( github.ref, 'staging' ) || contains( github.base_ref, 'staging' )
env:
APP_ENV: stag
run: echo "set APP_ENV to $APP_ENV"
- name: Build the Docker image
run: docker-compose build --pull --build-arg APP_ENV=$APP_ENV
- name: Run the docker image
run: docker-compose up -d
- name: Taking some sleep
run: sleep 100
- name: Check if all containers are running
run: docker ps
- name: Dumping the logs
run: docker-compose logs
- name: Security Checks
run: docker-compose exec -T php composer req sensiolabs/security-checker
- name: Chores
run: docker-compose down
- name: Login to DockerHub Registry
run: echo ${{ secrets.DOCKERHUB_PASSWORD }} | docker login -u ${{ secrets.DOCKERHUB_USERNAME }} --password-stdin
- name: Push to docker hub
run: docker-compose push

name: Docker Image CI

on:
pull_request:
branches:
- master
- staging
- development
push:
branches:
- master
- staging
- development

jobs:

build:

runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Set correct helm version
if: (contains( github.ref, 'master' ) || contains( github.ref, 'staging' ) || contains( github.ref, 'development' )) && steps.kubeconfig.outputs.success == 'true'
run: ./get_helm.sh -v v2.12.3
- name: Pulling old images, if any
run: docker-compose pull --ignore-pull-failures
- name: Setting APP_NAME
run: |
export NAME=$(grep APP_NAME= .env | cut -d '=' -f2)
echo ::set-env name=APP_NAME::$NAME
- name: Print app name
run: echo "APP_NAME = $APP_NAME"
- name: Setting APP_ENV to dev
run: |
echo ::set-env name=APP_ENV::dev
echo ::set-env name=APP_BUILD::dev
echo "set APP_ENV to $APP_ENV"
- name: Setting APP_ENV to prod
if: contains( github.ref, 'master' ) || contains( github.base_ref, 'master' )
run: |
echo ::set-env name=APP_ENV::prod
echo "set APP_ENV to $APP_ENV"
- name: Set APP_BUILD to APP_VERSION
if: contains( github.ref, 'master' )
run: |
export VERSION=$(grep APP_VERSION= .env | cut -d '=' -f2)
echo ::set-env name=APP_BUILD::$VERSION
echo "set APP_BUILD to $APP_BUILD"
- name: Setting APP_ENV to stag
if: contains( github.ref, 'staging' ) || contains( github.base_ref, 'staging' )
run: |
echo ::set-env name=APP_ENV::stag
echo ::set-env name=APP_BUILD::stag
echo "set APP_ENV to $APP_ENV"
- name: Print definitive APP_ENV
run: echo "APP_ENV is now $APP_ENV"
- name: Build the Docker image
run: docker-compose build --pull --build-arg APP_ENV=$APP_ENV
run: docker-compose build --pull --build-arg APP_ENV=$APP_ENV --build-arg APP_BUILD=$APP_BUILD
- name: Run the docker image
run: docker-compose up -d
- name: Taking some sleep
Expand Down Expand Up @@ -131,6 +87,29 @@ jobs:
else
echo "##[set-output name=success]false"
fi
- name: Set correct helm version
if: (contains( github.ref, 'master' ) || contains( github.ref, 'staging' ) || contains( github.ref, 'development' )) && steps.kubeconfig.outputs.success == 'true'
run: helm init --upgrade --kubeconfig="kubeconfig.yaml"
- name: Deploy through helm
if: (contains( github.ref, 'master' ) || contains( github.ref, 'staging' ) || contains( github.ref, 'development' )) && steps.kubeconfig.outputs.success == 'true'
run: helm install --name pc-$APP_ENV ./api/helm --kubeconfig="kubeconfig.yaml" --namespace=$APP_ENV --set settings.env=$APP_ENV,settings.debug=1,settings.loadbalancerEnabled=true
run: helm upgrade $APP_NAME-$APP_ENV ./api/helm --kubeconfig="kubeconfig.yaml" --namespace=$APP_ENV --set settings.env=$APP_ENV,settings.debug=1
- name: Install through helm
if: failure()
run: helm install --name $APP_NAME-$APP_ENV ./api/helm --kubeconfig="kubeconfig.yaml" --namespace=$APP_ENV --set settings.env=$APP_ENV,settings.debug=1
- name: Rollout new containers
if: (contains( github.ref, 'master' ) || contains( github.ref, 'staging' ) || contains( github.ref, 'development' )) && steps.kubeconfig.outputs.success == 'true' && steps.helm-install.success == 'true'
run: |
kubectl rollout restart deployment/$APP_NAME-php --kubeconfig="kubeconfig.yaml" --namespace=$APP_ENV
kubectl rollout restart deployment/$APP_NAME-nginx --kubeconfig="kubeconfig.yaml" --namespace=$APP_ENV
kubectl rollout restart deployment/$APP_NAME-varnish --kubeconfig="kubeconfig.yaml" --namespace=$APP_ENV
- name: Create Release
if: contains( github.ref, 'master' )
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
with:
tag_name: $APP_BUILD
release_name: $APP_BUILD
draft: false
prerelease: false
112 changes: 109 additions & 3 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 96e00ff

Please sign in to comment.