card2Card hide #940
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
name: CI | |
on: | |
push: | |
branches: [ master, dev, testnet, megachain, megagamer ] | |
env: | |
PRODUCTION_BRANCH: ( master, megachain, megagamer ) | |
INGRESS_DOMAIN_master: "my.honee.app" | |
INGRESS_DOMAIN_dev: "honee.dev" | |
INGRESS_DOMAIN_testnet: "testnet.honee.dev" | |
INGRESS_DOMAIN_megachain: "launchpad.metagarden.io" | |
INGRESS_DOMAIN_megagamer: "gamerid.metagarden.io" | |
KUBE_NAMESPACE_master: "honee" | |
KUBE_NAMESPACE_dev: "default" | |
KUBE_NAMESPACE_testnet: "default" | |
KUBE_NAMESPACE_megachain: "honee" | |
KUBE_NAMESPACE_megagamer: "honee" | |
jobs: | |
ci: | |
name: build | |
runs-on: ubuntu-latest | |
if: "!contains(github.event.head_commit.message, 'skip deploy')" | |
steps: | |
- name: set env BUILD_BRANCH | |
run: echo "BUILD_BRANCH=$(echo $GITHUB_REF | sed 's:refs/heads/::')" >> $GITHUB_ENV | |
- name: set branch prefix env to be used during docker build, .e.g. "refs/heads/testnet" => ".testnet" | |
run: echo "BUILD_BRANCH_ENV_PREFIX=$(echo .$BUILD_BRANCH)" >> $GITHUB_ENV | |
- name: set env PROJECT_NAME | |
run: echo "PROJECT_NAME=$(echo $GITHUB_REPOSITORY | sed 's:MinterTeam/::')" >> $GITHUB_ENV | |
- name: set env RELEASE_NAME | |
run: echo "RELEASE_NAME=$PROJECT_NAME-$BUILD_BRANCH" >> $GITHUB_ENV | |
- name: set env INGRESS_DOMAIN | |
env: | |
INGRESS_DOMAIN_KEY: INGRESS_DOMAIN_${{ env.BUILD_BRANCH }} | |
run: echo "INGRESS_DOMAIN=$(echo ${!INGRESS_DOMAIN_KEY})" >> $GITHUB_ENV | |
- name: set env KUBE_NAMESPACE | |
env: | |
KUBE_NAMESPACE_KEY: KUBE_NAMESPACE_${{ env.BUILD_BRANCH }} | |
run: echo "KUBE_NAMESPACE=$(echo ${!KUBE_NAMESPACE_KEY})" >> $GITHUB_ENV | |
- name: set env IMAGE_TAG_NAME | |
run: echo "IMAGE_TAG_NAME=$BUILD_BRANCH-$GITHUB_SHA" >> $GITHUB_ENV | |
- uses: actions/checkout@v2 | |
- name: build and push docker image | |
uses: opspresso/action-docker@v0.2.13 | |
env: | |
USERNAME: ${{ secrets.MINTER_REGISTRY_USERNAME }} | |
PASSWORD: ${{ secrets.MINTER_REGISTRY_PASSWORD }} | |
REGISTRY: "registry.minter.network" | |
IMAGE_NAME: ${{ env.PROJECT_NAME }} | |
LATEST: "true" | |
TAG_NAME: ${{ env.IMAGE_TAG_NAME }} | |
DOCKERFILE: ".docker/Dockerfile" | |
DOCKER_BUILD_ARGS: --build-arg BUILD_BRANCH_ENV_PREFIX | |
# - name: DigitalOcean Kubernetes | |
# if: env.BUILD_BRANCH == env.PRODUCTION_BRANCH | |
# uses: matootie/dokube@v1.3.4 | |
# with: | |
# personalAccessToken: ${{ secrets.DIGITALOCEAN_TOKEN }} | |
# clusterName: k8s-prod-do | |
# | |
# - name: Install helm to DO | |
# if: env.BUILD_BRANCH == env.PRODUCTION_BRANCH | |
# run: wget https://get.helm.sh/helm-v3.3.4-linux-amd64.tar.gz &> /dev/null && tar xvzf helm-v3.3.4-linux-amd64.tar.gz && chmod 777 linux-amd64/helm && ./linux-amd64/helm ls -n ${{ env.KUBE_NAMESPACE }} | |
# | |
# - name: Deploy to DO | |
# if: env.BUILD_BRANCH == env.PRODUCTION_BRANCH | |
# env: | |
# TAG_NAME: ${{ env.IMAGE_TAG_NAME }} | |
# run: ./linux-amd64/helm upgrade -n ${{ env.KUBE_NAMESPACE }} -i $RELEASE_NAME chart/ --atomic --timeout 100s --set image.tag=$TAG_NAME --set ingress.domain=$INGRESS_DOMAIN --set ingress.tlsname=$INGRESS_DOMAIN | |
- name: deploy to production cluster | |
if: contains(env.PRODUCTION_BRANCH, env.BUILD_BRANCH) | |
uses: wahyd4/kubectl-helm-action@v0.1.2 | |
env: | |
KUBE_CONFIG_DATA: ${{ secrets.KUBE_PROD_CONFIG_DATA }} | |
TAG_NAME: ${{ env.IMAGE_TAG_NAME }} | |
with: | |
args: helm upgrade -n $KUBE_NAMESPACE -i $RELEASE_NAME chart/ --atomic --timeout 100s --set image.tag=$TAG_NAME --set ingress.domain=$INGRESS_DOMAIN --set ingress.tlsname=$INGRESS_DOMAIN | |
- name: deploy to staging cluster | |
if: "!contains(env.PRODUCTION_BRANCH, env.BUILD_BRANCH)" | |
uses: wahyd4/kubectl-helm-action@master | |
env: | |
KUBE_CONFIG_DATA: ${{ secrets.KUBE_STAGE_CONFIG_DATA }} | |
TAG_NAME: ${{ env.IMAGE_TAG_NAME }} | |
with: | |
args: helm upgrade -n $KUBE_NAMESPACE -i $RELEASE_NAME chart/ --atomic --timeout 100s --set image.tag=$TAG_NAME --set ingress.domain=$INGRESS_DOMAIN --set ingress.tlsname=$INGRESS_DOMAIN --set ingress.issuer=letsencrypt-http --set ingress.clusterissuer="" | |
- name: notification | |
if: cancelled() == false | |
uses: xinthink/action-telegram@v1.1 | |
with: | |
botToken: ${{ secrets.TELEGRAM_CI_TOKEN }} | |
chatId: ${{ secrets.TELEGRAM_CI_TO }} | |
jobStatus: ${{ job.status }} | |
skipSuccess: false |