Skip to content

Fiddle: convert package to es-module (#217) #275

Fiddle: convert package to es-module (#217)

Fiddle: convert package to es-module (#217) #275

Workflow file for this run

name: Deploy
on:
push:
branches: [main]
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-deploy
cancel-in-progress: false
jobs:
deploy-package-next:
runs-on: ubuntu-latest
env:
DOCKER_IMAGE: package
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
steps:
- name: Check out the repo
uses: actions/checkout@v2
with:
# NOTE(krishan711): need full history to calculate difference
fetch-depth: 0
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Build docker image
uses: docker/build-push-action@v2
with:
context: .
load: true
cache-from: type=gha,scope=package
cache-to: type=gha,mode=max,scope=package
tags: ${{ env.DOCKER_IMAGE }}
- name: Calculate commit count since last tag
id: vars
run: echo ::set-output name=commit_count::$(git rev-list $(git describe --tags --abbrev=0)..HEAD --count)
- name: Create .npmrc file
run: echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > .npmrc
- name: Publish next package to npm
if: steps.vars.outputs.commit_count != '0'
run: docker run -v $(pwd)/.npmrc:/root/.npmrc $DOCKER_IMAGE make NEXT_VERSION=${{ steps.vars.outputs.commit_count }} publish-next
deploy-docs-next:
runs-on: ubuntu-latest
env:
DOCKER_IMAGE: ghcr.io/${{ github.repository }}-docs:next
steps:
- name: Check out the repo
uses: actions/checkout@v2
- name: Login to GitHub container registry
uses: docker/#-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Build docker image
uses: docker/build-push-action@v2
with:
context: .
push: true
cache-from: type=gha,scope=docs-app
cache-to: type=gha,mode=max,scope=docs-app
tags: ${{ env.DOCKER_IMAGE }}
file: ./docs.Dockerfile
run-docs-next:
needs: deploy-docs-next
runs-on: ubuntu-latest
env:
NAME: ui-react-docs-next
DOCKER_IMAGE: ghcr.io/${{ github.repository }}-docs:next
steps:
- name: executing remote ssh commands
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.KIBA_APP_BOX_URL }}
username: ${{ secrets.KIBA_APP_BOX_USER }}
key: ${{ secrets.KIBA_APP_BOX_SSH_KEY }}
port: ${{ secrets.KIBA_APP_BOX_PORT }}
envs: DOCKER_IMAGE,NAME
script_stop: true
script: |
url="ui-react-docs-next.kibalabs.com"
varsFile=~/.${NAME}.vars
docker pull ${DOCKER_IMAGE}
docker stop ${NAME} && docker rm ${NAME} || true
docker run \
--name ${NAME} \
--detach \
--publish-all \
--restart on-failure \
--env NAME=${NAME} \
--env VIRTUAL_HOST=${url} \
--env LETSENCRYPT_HOST=${url} \
--env-file ${varsFile} \
${DOCKER_IMAGE}