init commit
parent
18d468c8a2
commit
6f997e9621
@ -0,0 +1,74 @@
|
|||||||
|
name: Deploy to Amazon EC2(github -> package -> EC2 docker image)
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [ master ] # push할 때 동작할 branch를 입력해주세요.
|
||||||
|
workflow_dispatch:
|
||||||
|
inputs:
|
||||||
|
logLevel:
|
||||||
|
description: 'Log level'
|
||||||
|
required: true
|
||||||
|
default: 'debug'
|
||||||
|
tags:
|
||||||
|
description: 'Run action'
|
||||||
|
required: true
|
||||||
|
default: 'Run '
|
||||||
|
env:
|
||||||
|
#DOCKER_IMAGE: ghcr.io/{Repository author}/{Repository name} # 예를 들면, ghcr.io/dolphago/github-follow-unfollow
|
||||||
|
DOCKER_IMAGE: ghcr.io/${{ github.actor }}/xit-framework
|
||||||
|
VERSION: ${{ github.sha }}
|
||||||
|
NAME: xit-framework-bo
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
name: Build
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Check out source code
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
- name: Set up docker buildx
|
||||||
|
id: buildx
|
||||||
|
uses: docker/setup-buildx-action@v1
|
||||||
|
- name: Cache docker layers
|
||||||
|
uses: actions/cache@v2
|
||||||
|
with:
|
||||||
|
path: /tmp/.buildx-cache
|
||||||
|
key: ${{ runner.os }}-buildx-${{ env.VERSION }} # runner 설정에서 읽어들일거에요.
|
||||||
|
restore-keys: |
|
||||||
|
${{ runner.os }}-buildx-
|
||||||
|
- name: Login to ghcr
|
||||||
|
uses: docker/login-action@v1
|
||||||
|
with:
|
||||||
|
registry: ghcr.io
|
||||||
|
username: ${{ github.actor }}
|
||||||
|
password: ${{ secrets.GIT_ACS_TOKEN }}
|
||||||
|
- name: Build and push
|
||||||
|
id: docker_build
|
||||||
|
uses: docker/build-push-action@v2
|
||||||
|
with:
|
||||||
|
builder: ${{ steps.buildx.outputs.name }}
|
||||||
|
push: true #${{ github.event_name != 'pull_request' }}
|
||||||
|
tags: ${{ env.DOCKER_IMAGE }}:${{ env.VERSION }}
|
||||||
|
|
||||||
|
deploy:
|
||||||
|
needs: build
|
||||||
|
name: Deploy
|
||||||
|
runs-on: [ self-hosted, label-development ]
|
||||||
|
steps:
|
||||||
|
- name: Login to ghcr
|
||||||
|
uses: docker/login-action@v1
|
||||||
|
with:
|
||||||
|
registry: ghcr.io
|
||||||
|
username: ${{ github.actor }}
|
||||||
|
password: ${{ secrets.GIT_ACS_TOKEN }}
|
||||||
|
- name: Docker run
|
||||||
|
#docker ps -q --filter "name=xit-framework-bo" | grep -q . && docker stop xit-framework-bo && docker rm -fv xit-framework-bo
|
||||||
|
#docker run -d -p 8090:8090 --name xit-framework-bo --restart always ${{ env.DOCKER_IMAGE }}:${{ env.VERSION }}
|
||||||
|
#docker run -d -p 8090:8090 --name xit-framework-bo --restart always ${{ env.DOCKER_IMAGE }}:${{ env.VERSION }}
|
||||||
|
#docker ps -q --filter "name=xit-framework-bo" | grep -q . && docker stop xit-framework-bo && docker rm -fv xit-framework-bo
|
||||||
|
#docker stop ${{ env.NAME }} && docker rm ${{ env.NAME }} && docker rmi ${{ env.DOCKER_IMAGE }}:latest
|
||||||
|
run: |
|
||||||
|
docker run -d -p 8090:8090 --name ${{ env.NAME }} --restart always ${{ env.DOCKER_IMAGE }}:${{ env.VERSION }}
|
||||||
|
sleep 5
|
||||||
|
docker image prune -a
|
||||||
|
sleep 5
|
Loading…
Reference in New Issue