Fix the typo #7
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: Deploy | |
on: push | |
jobs: | |
deploy: | |
name: Deploy Grafana | |
runs-on: self-hosted | |
strategy: | |
matrix: | |
compose-file-context: | |
- { stack_name: 'grafana', host: 'tcp://192.168.2.108:2375' } | |
env: | |
DOCKER_HOST: ${{ matrix.compose-file-context.host }} | |
DOCKER_CONTEXT_NAME: ${{ matrix.compose-file-context.stack_name }}-ctx | |
DOCKER_PROJECT_NAME: ${{ matrix.compose-file-context.stack_name }} | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Run command on remote server via SSH | |
uses: appleboy/ssh-action@master | |
with: | |
host: '192.168.2.108' | |
username: 'root' | |
password: ${{ secrets.SSH_PASSWORD }} | |
script: | | |
cd /data/grafana | |
git pull origin main | |
- name: Set up Docker context | |
run: | | |
docker context \ | |
create ${{ env.DOCKER_CONTEXT_NAME }} \ | |
--docker host=${{ env.DOCKER_HOST }} | |
- name: Deploy with Docker Compose | |
run: | | |
docker --context ${{ env.DOCKER_CONTEXT_NAME }} compose pull | |
docker --context ${{ env.DOCKER_CONTEXT_NAME }} compose \ | |
--project-name ${{ env.DOCKER_PROJECT_NAME }} up -d --remove-orphans --force-recreate | |
- name: Cleanup Docker context | |
if: always() | |
run: | | |
docker context rm ${{ env.DOCKER_CONTEXT_NAME }} --force |