This repository has been archived by the owner on Sep 8, 2024. It is now read-only.
CD #128
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: CD | |
on: | |
workflow_run: | |
workflows: | |
- CI | |
branches: | |
- trunk | |
types: | |
- completed | |
jobs: | |
release: | |
if: ${{ github.event.workflow_run.conclusion == 'success' }} | |
name: Release Docker images | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
with: | |
fetch-depth: 0 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v1 | |
- name: Fetch git describe | |
id: describe | |
run: echo ::set-output name=describe::$(git describe) | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v1 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build and push latest version | |
uses: docker/build-push-action@v2 | |
with: | |
push: true | |
tags: ghcr.io/${{ github.repository }}/makibot:latest | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
build-args: VERSION_TAG=${{ steps.describe.outputs.describe }} | |
deploy: | |
name: Deploy into my server | |
needs: [release] | |
runs-on: ubuntu-latest | |
environment: public | |
steps: | |
- name: Run docker-compose remotely | |
uses: appleboy/ssh-action@master | |
with: | |
host: ${{ secrets.SSH_HOST }} | |
username: ${{ secrets.SSH_USERNAME }} | |
key: ${{ secrets.SSH_KEY }} | |
passphrase: ${{ secrets.SSH_PASSPHRASE }} | |
script: | | |
docker-compose --project-directory docker/makibot pull makibot | |
docker-compose --project-directory docker/makibot up -d |