Add super fast deploy script. Build/Cached local.
This commit is contained in:
parent
3d7088a6bf
commit
fca70628db
2 changed files with 80 additions and 1 deletions
79
.github/workflows/local-build-push.yaml
vendored
Normal file
79
.github/workflows/local-build-push.yaml
vendored
Normal file
|
|
@ -0,0 +1,79 @@
|
|||
|
||||
name: local-build
|
||||
run-name: local-build ${{ github.actor }}
|
||||
on:
|
||||
# push:
|
||||
# tags:
|
||||
# - v1.**
|
||||
# branches:
|
||||
# - 'main'
|
||||
# branches:
|
||||
# - 'release-*'
|
||||
|
||||
# Allow run workflow manually from Action tab
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
IMAGE_VER:
|
||||
description: "version for build image"
|
||||
type: string
|
||||
|
||||
env:
|
||||
REGISTRY: docker.frappet.com
|
||||
IMAGE_NAME: demo/qualifying-exam-cms
|
||||
DEPLOY_HOST: frappet.com
|
||||
COMPOSE_PATH: /home/frappet/docker/bma-ehr-qualifying-cms
|
||||
|
||||
jobs:
|
||||
# act workflow_dispatch --reuse -W .github/workflows/local-build-push.yaml --input IMAGE_VER=v0.2.17-dev -s DOCKER_USER=sorawit -s DOCKER_PASS=P@ssword -s SSH_PASSWORD=P@ssw0rd
|
||||
local-image:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Check out code # checkout only cms is possible but I checkout all
|
||||
uses: actions/checkout@v3
|
||||
- name: Gen Version
|
||||
id: gen_ver
|
||||
run: |
|
||||
IMAGE_VER=${{ github.event.inputs.IMAGE_VER }}
|
||||
echo "{\"version\":\"$IMAGE_VER\", \"builddate\":\"$(date +"%Y-%m-%d_%T")\",\"ref_name\":\"$GITHUB_REF\" }" > ./cms/src/lib/ver.json
|
||||
cat ./cms/src/lib/ver.json
|
||||
echo '::set-output name=image_ver::'$IMAGE_VER
|
||||
- name: Debug act
|
||||
if: ${{ env.ACT }}
|
||||
run: |
|
||||
echo $GITHUB_REF
|
||||
echo ${{ steps.gen_ver.outputs.image_ver }}
|
||||
cat ./cms/src/lib/ver.json
|
||||
- name: Login in to registry
|
||||
uses: docker/login-action@v2
|
||||
with:
|
||||
registry: ${{env.REGISTRY}}
|
||||
username: ${{secrets.DOCKER_USER}}
|
||||
password: ${{secrets.DOCKER_PASS}}
|
||||
|
||||
- name: Build and push docker image
|
||||
uses: docker/build-push-action@v4
|
||||
with:
|
||||
context: cms
|
||||
load: true
|
||||
cache-from: type=gha
|
||||
cache-to: type=gha,mode=max
|
||||
# cache-from: type=local,src=/tmp/.buildx-cache
|
||||
# cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max
|
||||
tags: ${{env.REGISTRY}}/${{env.IMAGE_NAME}}:${{ steps.gen_ver.outputs.image_ver }},${{env.REGISTRY}}/${{env.IMAGE_NAME}}:latest
|
||||
- name: Push image to registry
|
||||
run: |
|
||||
docker push ${{env.REGISTRY}}/${{env.IMAGE_NAME}}:${{ steps.gen_ver.outputs.image_ver }}
|
||||
docker push ${{env.REGISTRY}}/${{env.IMAGE_NAME}}:latest
|
||||
- name: Remote Deployment
|
||||
uses: appleboy/ssh-action@v0.1.8
|
||||
with:
|
||||
host: ${{env.DEPLOY_HOST}}
|
||||
username: frappet
|
||||
password: ${{ secrets.SSH_PASSWORD }}
|
||||
port: 22
|
||||
script: |
|
||||
cd "${{env.COMPOSE_PATH}}"
|
||||
docker-compose pull
|
||||
docker-compose up -d
|
||||
echo "${{ steps.gen_ver.outputs.image_ver }}"> success
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue