From 217cfa40290e66c7685778ea8b930ebc9c7b9545 Mon Sep 17 00:00:00 2001 From: Joost Date: Wed, 25 Mar 2020 20:14:16 +0100 Subject: [PATCH 1/6] Added linter and release GitHub-Action! --- .github/workflows/dockerimage.yml | 22 ------------ .github/workflows/linter.yaml | 24 +++++++++++++ .github/workflows/release.yml | 56 +++++++++++++++++++++++++++++++ 3 files changed, 80 insertions(+), 22 deletions(-) delete mode 100644 .github/workflows/dockerimage.yml create mode 100644 .github/workflows/linter.yaml create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/dockerimage.yml b/.github/workflows/dockerimage.yml deleted file mode 100644 index 2324f18d..00000000 --- a/.github/workflows/dockerimage.yml +++ /dev/null @@ -1,22 +0,0 @@ -name: Docker Image CI - -on: - push: - branches: - - master - - releases/* - pull_request: - branches: - - master - - releases/* - -jobs: - - build: - - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v2 - - name: Build the Docker image - run: docker build . --file Dockerfile --tag my-image-name:$(date +%s) diff --git a/.github/workflows/linter.yaml b/.github/workflows/linter.yaml new file mode 100644 index 00000000..f565cdca --- /dev/null +++ b/.github/workflows/linter.yaml @@ -0,0 +1,24 @@ +name: Linter + +# Trigger on push +on: push + +jobs: + lint: + runs-on: ubuntu-latest + + steps: + - name: Echo + run: echo "Here a linter should be invoked" + + build: + name: Build image + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@master + + - name: Push to docker hub :latest + uses: actions-hub/docker@master + with: + args: build . \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..45142bb4 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,56 @@ +name: Release + +on: + release: + types: [created] + +jobs: + build: + name: Build+Publish image + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@master + + - name: Login to registry + if: success() + uses: actions-hub/docker/login@master + env: + DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} + DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} + + - name: Build image + if: success() + run: docker build -t ${GITHUB_REPOSITORY}:release-${GITHUB_REF} . + + - name: Tag image + if: success() + run: docker tag ${GITHUB_REPOSITORY}:release-${GITHUB_REF} ${GITHUB_REPOSITORY}:latest + + - name: Push :release- + if: success() + uses: actions-hub/docker@master + with: + args: push ${GITHUB_REPOSITORY}:${GITHUB_REF} + + - name: Push :latest + if: success() + uses: actions-hub/docker@master + with: + args: push ${GITHUB_REPOSITORY}:release-${GITHUB_REF} + + + deploy: + needs: build + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + with: + repository: 'SAKPaaS/deployment' + + - uses: actions-hub/kubectl@master + env: + KUBE_CONFIG: ${{ secrets.KUBE_CONFIG }} + with: + args: rolling-update sakpaas-backend --image=${GITHUB_REPOSITORY}:release-${GITHUB_REF} From b771aefdae69d1a6cff58ca7e9d090f20ded254b Mon Sep 17 00:00:00 2001 From: Joost Date: Wed, 25 Mar 2020 20:20:47 +0100 Subject: [PATCH 2/6] Added missing docker login --- .github/workflows/linter.yaml | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/.github/workflows/linter.yaml b/.github/workflows/linter.yaml index f565cdca..039e84f0 100644 --- a/.github/workflows/linter.yaml +++ b/.github/workflows/linter.yaml @@ -5,9 +5,12 @@ on: push jobs: lint: + name: Run Linter runs-on: ubuntu-latest steps: + - uses: actions/checkout@master + - name: Echo run: echo "Here a linter should be invoked" @@ -18,7 +21,15 @@ jobs: steps: - uses: actions/checkout@master - - name: Push to docker hub :latest + - name: Login to registry + if: success() + uses: actions-hub/docker/login@master + env: + DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} + DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} + + - name: Build image + if: success() uses: actions-hub/docker@master with: args: build . \ No newline at end of file From c999687cf4d78a5d5e71c03b38f5a41e6b52554a Mon Sep 17 00:00:00 2001 From: Joost Date: Wed, 25 Mar 2020 23:25:12 +0100 Subject: [PATCH 3/6] Added integration workflow --- .github/workflows/integration.yaml | 45 ++++++++++++++++++++++++++++++ .github/workflows/linter.yaml | 20 ------------- 2 files changed, 45 insertions(+), 20 deletions(-) create mode 100644 .github/workflows/integration.yaml diff --git a/.github/workflows/integration.yaml b/.github/workflows/integration.yaml new file mode 100644 index 00000000..8d3d94cf --- /dev/null +++ b/.github/workflows/integration.yaml @@ -0,0 +1,45 @@ +name: Integration + +# TODO: Change to push to "master" +on: push + +jobs: + build: + name: Build+Publish image + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@master + + - name: Login to registry + if: success() + uses: actions-hub/docker/login@master + env: + DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} + DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} + + - name: Build image + if: success() + run: docker build -t ${GITHUB_REPOSITORY}:development . + + - name: Push :development + if: success() + uses: actions-hub/docker@master + with: + args: push ${GITHUB_REPOSITORY}:development + + + deploy: + needs: build + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + with: + repository: 'SAKPaaS/deployment' + + - uses: actions-hub/kubectl@master + env: + KUBE_CONFIG: ${{ secrets.KUBE_CONFIG }} + with: + args: version diff --git a/.github/workflows/linter.yaml b/.github/workflows/linter.yaml index 039e84f0..79f7f8d4 100644 --- a/.github/workflows/linter.yaml +++ b/.github/workflows/linter.yaml @@ -13,23 +13,3 @@ jobs: - name: Echo run: echo "Here a linter should be invoked" - - build: - name: Build image - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@master - - - name: Login to registry - if: success() - uses: actions-hub/docker/login@master - env: - DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} - DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} - - - name: Build image - if: success() - uses: actions-hub/docker@master - with: - args: build . \ No newline at end of file From 7a50459f44d1400d9df3cba09aae5871983af0e7 Mon Sep 17 00:00:00 2001 From: Joost Date: Wed, 25 Mar 2020 23:34:40 +0100 Subject: [PATCH 4/6] Added docker repository --- .github/workflows/integration.yaml | 4 ++-- .github/workflows/release.yml | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/integration.yaml b/.github/workflows/integration.yaml index 8d3d94cf..d661193a 100644 --- a/.github/workflows/integration.yaml +++ b/.github/workflows/integration.yaml @@ -20,13 +20,13 @@ jobs: - name: Build image if: success() - run: docker build -t ${GITHUB_REPOSITORY}:development . + run: docker build -t sakpaas/backend:development . - name: Push :development if: success() uses: actions-hub/docker@master with: - args: push ${GITHUB_REPOSITORY}:development + args: push sakpaas/backend:development deploy: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 45142bb4..c47f6ac0 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -21,23 +21,23 @@ jobs: - name: Build image if: success() - run: docker build -t ${GITHUB_REPOSITORY}:release-${GITHUB_REF} . + run: docker build -t sakpaas/backend:release-${GITHUB_REF} . - name: Tag image if: success() - run: docker tag ${GITHUB_REPOSITORY}:release-${GITHUB_REF} ${GITHUB_REPOSITORY}:latest + run: docker tag sakpaas/backend:release-${GITHUB_REF} sakpaas/backend:latest - name: Push :release- if: success() uses: actions-hub/docker@master with: - args: push ${GITHUB_REPOSITORY}:${GITHUB_REF} + args: push sakpaas/backend:${GITHUB_REF} - name: Push :latest if: success() uses: actions-hub/docker@master with: - args: push ${GITHUB_REPOSITORY}:release-${GITHUB_REF} + args: push sakpaas/backend:release-${GITHUB_REF} deploy: @@ -53,4 +53,4 @@ jobs: env: KUBE_CONFIG: ${{ secrets.KUBE_CONFIG }} with: - args: rolling-update sakpaas-backend --image=${GITHUB_REPOSITORY}:release-${GITHUB_REF} + args: rolling-update sakpaas-backend --image=sakpaas/backend:release-${GITHUB_REF} From f0c4908ffb29a673a8c9685d1c82c2a1a9d69039 Mon Sep 17 00:00:00 2001 From: Joost Date: Thu, 26 Mar 2020 19:09:02 +0100 Subject: [PATCH 5/6] Added development environment to workflows --- .github/workflows/integration.yaml | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/.github/workflows/integration.yaml b/.github/workflows/integration.yaml index d661193a..5f502c1d 100644 --- a/.github/workflows/integration.yaml +++ b/.github/workflows/integration.yaml @@ -20,26 +20,35 @@ jobs: - name: Build image if: success() - run: docker build -t sakpaas/backend:development . + run: docker build -t sakpaas/backend:dev-${GITHUB_SHA} . - name: Push :development if: success() uses: actions-hub/docker@master with: - args: push sakpaas/backend:development + args: push sakpaas/backend:dev-${GITHUB_SHA} deploy: + name: Deployment needs: build runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - name: Checkout + uses: actions/checkout@v2 with: repository: 'SAKPaaS/deployment' - - uses: actions-hub/kubectl@master + - name: Kustomize + uses: stefanprodan/kube-tools@v1 + with: + kustomize: 3.4.0 + command: "cd backend/development && kustomize edit set image sakpaas/backend=sakpaas/backend:dev-${GITHUB_SHA}" + + - name: Deploy + uses: actions-hub/kubectl@master env: KUBE_CONFIG: ${{ secrets.KUBE_CONFIG }} with: - args: version + args: apply -k backend/development From a84a96cbbb391d7fd9dc59dc44bbb665e6e5a9b6 Mon Sep 17 00:00:00 2001 From: Joost Date: Thu, 26 Mar 2020 19:28:17 +0100 Subject: [PATCH 6/6] Finished release workflow and added events --- .../{integration.yaml => development.yaml} | 9 +++++---- .github/workflows/release.yml | 17 +++++++++++++---- 2 files changed, 18 insertions(+), 8 deletions(-) rename .github/workflows/{integration.yaml => development.yaml} (93%) diff --git a/.github/workflows/integration.yaml b/.github/workflows/development.yaml similarity index 93% rename from .github/workflows/integration.yaml rename to .github/workflows/development.yaml index 5f502c1d..099cb688 100644 --- a/.github/workflows/integration.yaml +++ b/.github/workflows/development.yaml @@ -1,11 +1,12 @@ -name: Integration +name: Development -# TODO: Change to push to "master" -on: push +on: + pull_request: + types: [closed] jobs: build: - name: Build+Publish image + name: Build+Push image runs-on: ubuntu-latest steps: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index c47f6ac0..7c97169c 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -6,7 +6,7 @@ on: jobs: build: - name: Build+Publish image + name: Build+Push image runs-on: ubuntu-latest steps: @@ -41,16 +41,25 @@ jobs: deploy: + name: Deployment needs: build runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - name: Checkout + uses: actions/checkout@v2 with: repository: 'SAKPaaS/deployment' - - uses: actions-hub/kubectl@master + - name: Kustomize + uses: stefanprodan/kube-tools@v1 + with: + kustomize: 3.4.0 + command: "cd backend/production && kustomize edit set image sakpaas/backend=sakpaas/backend:release-${GITHUB_REF}" + + - name: Deploy + uses: actions-hub/kubectl@master env: KUBE_CONFIG: ${{ secrets.KUBE_CONFIG }} with: - args: rolling-update sakpaas-backend --image=sakpaas/backend:release-${GITHUB_REF} + args: apply -k backend/production