MinecraftStatus/.forgejo/workflows/deploy.yml
2026-09-25 22:18:36 -06:00

54 lines
No EOL
1.7 KiB
YAML

name: Build & Deploy MSTBot
on:
push:
branches:
- master
tags:
- "v*.*.*" # only match version tags like v1.0.0
jobs:
build-and-deploy:
name: Build, push & deploy
runs-on: docker-cli-node24
steps:
- name: Checkout code
uses: actions/checkout@v5
- name: Build & push image
run: |
IMAGE="${{ vars.REGISTRY_URL }}/minecraftstatus/mstbot"
docker build --network=host -t $IMAGE:latest .
docker push $IMAGE:latest
if [[ "${{ github.ref }}" =~ ^refs/tags ]]; then
VERSION_TAG="${{ github.ref_name }}"
docker tag $IMAGE:latest $IMAGE:$VERSION_TAG
docker push $IMAGE:$VERSION_TAG
fi
- name: Deploy to LXC
uses: https://github.com/appleboy/ssh-action@v1
with:
host: ${{ vars.MSTBOT_HOST }}
username: ${{ vars.MSTBOT_USER }}
key: ${{ secrets.MSTBOT_SSH_KEY }}
script: |
set -euo pipefail
cd /opt/mstbot
curl -f -H "Authorization: token ${{ secrets.FORGEJO_TOKEN }}" -o docker-compose.yml "https://git.benrmorgan.com/api/v1/repos/bMorgan/MinecraftStatus/raw/main/docker-compose.yml"
docker compose down
docker compose pull
docker compose up -d
- name: Create Release
if: startsWith(github.ref, 'refs/tags/')
uses: actions/forgejo-release@v2.7.3
with:
direction: upload
title: ${{ github.ref_name }}
tag: ${{ github.ref_name }}
token: ${{ secrets.FORGEJO_TOKEN }}
release-dir: .
release-notes-assistant: true