Files
chat-api/.gitea/workflows/release.yml
T
LucasDLTG 37c5f1863f
CI / Rust CI (push) Successful in 1m10s
Publish & Deploy / Build and Push to Registry (push) Successful in 12s
Publish & Deploy / Deploy via SSH (push) Failing after 6s
fix: add key in scp
2026-04-09 17:26:31 +02:00

90 lines
2.6 KiB
YAML

name: Publish & Deploy
on:
push:
tags:
- 'v*'
permissions:
contents: write
actions: read
jobs:
build-and-push:
name: Build and Push to Registry
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Prepare Repo Name
id: repo_name
run: |
echo "REPO_LOWER=$(echo ${{ github.repository }} | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV
- name: Login to Gitea Registry
uses: https://github.com/docker/login-action@v3
with:
registry: https://gitea.iceberg.black
username: docker-bot
password: ${{ secrets.CONTAINER_REGISTRY_TOKEN }}
- name: Build and Push
uses: https://github.com/docker/build-push-action@v5
with:
context: .
push: true
tags: |
gitea.iceberg.black/${{ env.REPO_LOWER }}:${{ github.ref_name }}
- name: Link package to repository
run: |
PKG_NAME=${REPO_LOWER#*/}
OWNER=${REPO_LOWER%/*}
RESPONSE=$(curl -s -w "\nHTTP_STATUS:%{http_code}" -X POST \
"https://gitea.iceberg.black/api/v1/packages/${OWNER}/container/${PKG_NAME}/-/link/${PKG_NAME}" \
-H "Authorization: token ${{ secrets.CONTAINER_REGISTRY_TOKEN }}")
echo "Link response: $RESPONSE"
deploy:
name: Deploy via SSH
needs: build-and-push
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v4
- name: Copy docker-compose to server
run: |
echo "${{ secrets.SSH_PRIVATE_KEY }}" > key.pem
chmod 600 key.pem
rsync -avz -e "ssh -i key.pem -o StrictHostKeyChecking=no" \
docker-compose.yml \
bot@${{ secrets.SSH_HOST }}:/home/shared/iceberg/chat/chat-api/
- name: Execute remote deployment
uses: appleboy/ssh-action@v1.0.3
with:
host: ${{ secrets.SSH_HOST }}
username: bot
key: ${{ secrets.SSH_PRIVATE_KEY }}
script: |
REPO_LOWER=$(echo "${{ github.repository }}" | tr '[:upper:]' '[:lower:]')
TAG=${{ github.ref_name }}
echo "${{ secrets.CONTAINER_REGISTRY_TOKEN }}" | docker login gitea.iceberg.black -u "docker-bot" --password-stdin
docker pull gitea.iceberg.black/$REPO_LOWER:$TAG
docker logout gitea.iceberg.black
docker stop chat || true
docker rm chat || true
cd /home/shared/iceberg/chat/chat-api
docker compose up -d
docker image prune -af