Merge pull request #18 from depromeet/feat/local-docker/#17 #5
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: Atcha Deploy with Docker | |
on: | |
push: | |
branches: [ dev ] | |
env: | |
DOCKER_IMAGE: ghcr.io/jiwonkkang/atcha | |
VERSION: ${{ github.sha }} | |
CONTAINER_NAME: atcha | |
jobs: | |
build: | |
name: Build | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 # git 레파지토리를 클론하는것과 같음 | |
- name: Setup 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 }} | |
restore-keys: | | |
${{ runner.os }}-buildx- | |
- name: Login to ghcr | |
uses: docker/#-action@v1 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GHCR_TOKEN }} | |
- name: Build and push | |
id: docker_build | |
uses: docker/build-push-action@v2 | |
with: | |
builder: ${{ steps.buildx.outputs.name }} | |
push: true | |
tags: ${{ env.DOCKER_IMAGE }}:latest | |
deploy: | |
needs: build | |
name: Deploy | |
runs-on: ubuntu-latest | |
steps: | |
- name: Docker login | |
uses: appleboy/ssh-action@master | |
with: | |
host: ${{ secrets.REMOTE_IP }} | |
username: ${{ secrets.REMOTE_SSH_ID }} | |
password: ${{ secrets.REMOTE_SSH_PASSWORD }} | |
port: ${{ secrets.REMOTE_SSH_PORT }} | |
script: | | |
sudo chmod 666 /var/run/docker.sock | |
echo ${{ secrets.GHCR_TOKEN }} | docker login ghcr.io -u ${{ github.actor }} --password-stdin | |
- name: Run | |
uses: appleboy/ssh-action@master | |
with: | |
host: ${{ secrets.REMOTE_IP }} | |
username: ${{ secrets.REMOTE_SSH_ID }} | |
password: ${{ secrets.REMOTE_SSH_PASSWORD }} | |
port: ${{ secrets.REMOTE_SSH_PORT }} | |
script: | | |
./deploy.sh |