Skip to content

Commit

Permalink
Merge pull request #7 from QMSTR/fix-deprecated-set-env-ci-command
Browse files Browse the repository at this point in the history
Fixed broken CI/CD
  • Loading branch information
marcomicera authored Dec 17, 2020
2 parents e2d0401 + 6fff778 commit 6f14b29
Showing 1 changed file with 158 additions and 105 deletions.
263 changes: 158 additions & 105 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,127 +1,180 @@
# This is a basic workflow to help you get started with Actions
# Demodemo
name: Publish Docker
on:
push:
name: Build, push, and deploy
on: push

# Environment variables available to all jobs and steps in this workflow
env:
GKE_PROJECT: ${{ secrets.GKE_PROJECT }}
GKE_CLUSTER: qmstr-dev
GKE_CLUSTER: fasten
GKE_ZONE: europe-west3-a
GOBUILDER_IMAGE: "golang:1.12-buster"

jobs:

build-master:
runs-on: ubuntu-latest
steps:

- name: Checkout VCS
uses: actions/checkout@master
- name: Checkout
uses: actions/checkout@v2
- name: Prepare
id: prep
run: |
DOCKER_IMAGE=endocodeci/qmstr-master
TAGS="${DOCKER_IMAGE}:sha-${GITHUB_SHA::7}"
echo ::set-output name=tags::${TAGS}
echo ::set-output name=created::$(date -u +'%Y-%m-%dT%H:%M:%SZ')
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Cache Docker layers
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Login to DockerHub
if: github.event_name != 'pull_request'
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build and push
uses: docker/build-push-action@v2
with:
context: .
file: docker/qmstr-master/Dockerfile
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.prep.outputs.tags }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache,mode=max
labels: |
org.opencontainers.image.source=${{ github.event.repository.html_url }}
org.opencontainers.image.created=${{ steps.prep.outputs.created }}
org.opencontainers.image.revision=${{ github.sha }}
- name: Set env
run: echo ::set-env name=DOCKER_BUILDKIT::1

- name: Build and Push
uses: docker/build-push-action@v1
with:
repository: endocodeci/qmstr-master
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
dockerfile: docker/qmstr-master/Dockerfile
tag_with_sha: true
push: true

build-client:
runs-on: ubuntu-latest
steps:

- name: Checkout VCS
uses: actions/checkout@master

- name: Set env
run: |
echo ::set-env name=GITHUB_SHA_SHORT::$(git rev-parse --short $GITHUB_SHA)
echo ::set-env name=DOCKER_BUILDKIT::1
- name: Build and Push Base Client
uses: docker/build-push-action@v1
with:
repository: endocodeci/qmstr-client
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
dockerfile: docker/qmstr-client/Dockerfile
target: base
tag_with_sha: true

- name: Build and Push Maven Client
uses: docker/build-push-action@v1
with:
repository: endocodeci/qmstr-client-mvn
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
dockerfile: docker/qmstr-client/Dockerfile
target: mvn
tag_with_sha: true
- name: Checkout
uses: actions/checkout@v2
- name: Prepare
id: prep
run: |
DOCKER_IMAGE=endocodeci/qmstr-client
DOCKER_IMAGE_MVN=endocodeci/qmstr-client-mvn
TAGS="${DOCKER_IMAGE}:sha-${GITHUB_SHA::7}"
TAGS_MVN="${DOCKER_IMAGE_MVN}:sha-${GITHUB_SHA::7}"
echo ::set-output name=tags::${TAGS}
echo ::set-output name=tags-mvn::${TAGS_MVN}
echo ::set-output name=created::$(date -u +'%Y-%m-%dT%H:%M:%SZ')
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Cache Docker layers
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Login to DockerHub
if: github.event_name != 'pull_request'
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build and push base client
uses: docker/build-push-action@v2
with:
context: .
file: docker/qmstr-client/Dockerfile
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.prep.outputs.tags }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache,mode=max
labels: |
org.opencontainers.image.source=${{ github.event.repository.html_url }}
org.opencontainers.image.created=${{ steps.prep.outputs.created }}
org.opencontainers.image.revision=${{ github.sha }}
- name: Build and push Maven client
uses: docker/build-push-action@v2
with:
context: .
file: docker/qmstr-client/Dockerfile
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.prep.outputs.tags-mvn }}
labels: |
org.opencontainers.image.source=${{ github.event.repository.html_url }}
org.opencontainers.image.created=${{ steps.prep.outputs.created }}
org.opencontainers.image.revision=${{ github.sha }}
build-init-containers:
runs-on: ubuntu-latest
steps:

- name: Checkout VCS
uses: actions/checkout@master

- name: Set env
run: |
echo ::set-env name=GITHUB_SHA_SHORT::$(git rev-parse --short $GITHUB_SHA)
- name: Build and push endocodeci/pom-patch
uses: docker/build-push-action@v1
with:
repository: endocodeci/pom-patch
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
dockerfile: docker/init/pom-patch/Dockerfile
tag_with_sha: true
- name: Checkout
uses: actions/checkout@v2
- name: Prepare
id: prep
run: |
DOCKER_IMAGE=endocodeci/pom-patch
TAGS="${DOCKER_IMAGE}:sha-${GITHUB_SHA::7}"
echo ::set-output name=tags::${TAGS}
echo ::set-output name=created::$(date -u +'%Y-%m-%dT%H:%M:%SZ')
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Cache Docker layers
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Login to DockerHub
if: github.event_name != 'pull_request'
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build and push
uses: docker/build-push-action@v2
with:
context: .
file: docker/init/pom-patch/Dockerfile
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.prep.outputs.tags }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache,mode=max
labels: |
org.opencontainers.image.source=${{ github.event.repository.html_url }}
org.opencontainers.image.created=${{ steps.prep.outputs.created }}
org.opencontainers.image.revision=${{ github.sha }}
deploy-to-dev:
runs-on: ubuntu-latest
needs: [build-master, build-client, build-init-containers]

needs: [ build-master, build-client, build-init-containers ]
steps:

- name: Checkout VCS
uses: actions/checkout@master

- name: Set env
run: echo ::set-env name=GITHUB_SHA_SHORT::$(git rev-parse --short $GITHUB_SHA)

- name: Setup Google SDK
uses: GoogleCloudPlatform/github-actions/setup-gcloud@master
with:
version: '270.0.0'
service_account_email: ${{ secrets.SA_EMAIL_DEPLOY_QMSTR_DEV }}
service_account_key: ${{ secrets.SA_KEY_DEPLOY_QMSTR_DEV }}

- name: Setup Kustomize
uses: imranismail/setup-kustomize@master
with:
kustomize-version: "3.2.1"

- name: Make kustomize executable
run: chmod +x /opt/hostedtoolcache/kustomize/3.2.1/x64/kustomize

- name: Deploy to Dev Cluster
run: |
gcloud container clusters get-credentials $GKE_CLUSTER \
--zone $GKE_ZONE --project $GKE_PROJECT
cd ./deploy
export SHA_TAG="sha-${{ env.GITHUB_SHA_SHORT }}"
export NAMESPACE="qmstr-$SHA_TAG"
kubectl create namespace $NAMESPACE
kustomize edit set namespace $NAMESPACE
kustomize edit set image endocodeci/qmstr-master:$SHA_TAG
kustomize edit set image endocodeci/qmstr-client-mvn:$SHA_TAG
kustomize edit set image endocodeci/pom-patch:$SHA_TAG
kustomize build . | kubectl apply -f -
- name: Checkout VCS
uses: actions/checkout@master
- name: Setup Google SDK
uses: google-github-actions/setup-gcloud@master
with:
version: '270.0.0'
service_account_email: ${{ secrets.SA_EMAIL_DEPLOY_QMSTR_DEV }}
service_account_key: ${{ secrets.SA_KEY_DEPLOY_QMSTR_DEV }}
- name: Setup Kustomize
uses: imranismail/setup-kustomize@master
with:
kustomize-version: "3.2.1"
- name: Make kustomize executable
run: chmod +x /opt/hostedtoolcache/kustomize/3.2.1/x64/kustomize
- name: Deploy to Dev Cluster
run: |
gcloud container clusters get-credentials $GKE_CLUSTER \
--zone $GKE_ZONE --project $GKE_PROJECT
cd ./deploy
export SHA_TAG="sha-${GITHUB_SHA::7}"
export NAMESPACE="qmstr-$SHA_TAG"
kubectl create namespace $NAMESPACE
kustomize edit set namespace $NAMESPACE
kustomize edit set image endocodeci/qmstr-master:$SHA_TAG
kustomize edit set image endocodeci/qmstr-client-mvn:$SHA_TAG
kustomize edit set image endocodeci/pom-patch:$SHA_TAG
kustomize build . | kubectl apply -f -

0 comments on commit 6f14b29

Please sign in to comment.