MinecraftStatus/.forgejo/workflows/deploy.yml

73 lines
No EOL
2.3 KiB
YAML

name: Build & Deploy MSTBot
on:
push:
branches:
- master
tags:
- "v*.*.*" # only match version tags like v1.0.0
jobs:
prepare:
name: Build & push runner image
runs-on: docker-cli-node24
steps:
- name: Checkout runner Dockerfile
uses: actions/checkout@v5
with:
sparse-checkout: |
.forgejo/runner/Dockerfile
sparse-checkout-cone-mode: false
fetch-depth: 1
- name: Build & push runner image
run: |
docker build --network=host -t ${{ vars.REGISTRY_URL }}/minecraftstatus/runner:latest -f .forgejo/runner/Dockerfile .
docker push ${{ vars.REGISTRY_URL }}/minecraftstatus/runner:latest
build-and-deploy:
name: Build, push & deploy
runs-on: docker-cli-node24
container:
image: ${{ vars.REGISTRY_URL }}/minecraftstatus/runner:latest
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/master/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