Files
zkldi_Tachi/.github/workflows/github-bot.yml
T
2026-05-08 17:44:07 +00:00

72 lines
2.2 KiB
YAML

name: GitHub Bot CI/CD
on:
push:
branches:
- "main"
paths:
- "github-bot/**"
- "docker/Dockerfile.ghbot"
- ".github/workflows/github-bot.yml"
workflow_dispatch:
permissions:
contents: read
jobs:
docker-push:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
persist-credentials: false
- name: Log in to GHCR
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3.3.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@c47758b77c9736f4b2ef4073d4d51994fabfe349 # v3.7.1
- name: Build and push
uses: docker/build-push-action@48aba3b46d1b1fec4febb7c5d0c644b249a11355 # v6.10.0
with:
context: .
file: docker/Dockerfile.ghbot
push: ${{ github.ref == 'refs/heads/main' }}
provenance: true
sbom: true
tags: |
ghcr.io/zkldi/tachi-ghbot:${{ github.sha }}
ghcr.io/zkldi/tachi-ghbot:main
ghcr.io/zkldi/tachi-ghbot:latest
cache-from: type=gha,scope=${{ github.ref_name }}-github-bot
cache-to: type=gha,mode=max,scope=${{ github.ref_name }}-github-bot
deploy:
runs-on: ubuntu-latest
needs: [docker-push]
if: ${{ github.ref == 'refs/heads/main' && (github.event_name == 'push' || github.event_name == 'workflow_dispatch') }}
steps:
- name: Enable SSH
env:
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
SSH_KNOWN_HOSTS: ${{ secrets.SSH_KNOWN_HOSTS }}
run: |
mkdir -p ~/.ssh
printf '%s' "$SSH_PRIVATE_KEY" > ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa
printf '%s' "$SSH_KNOWN_HOSTS" > ~/.ssh/known_hosts
- name: Deploy updates
env:
TACHI_HOST: ${{ secrets.TACHI_HOST }}
run: ssh "ci@${TACHI_HOST}" "/home/ci/tachi-deploy/swarm/scripts/deploy-ghbot.sh ${{ github.sha }}"