fix: Replace GitHub Actions with native git commands for Gitea compatibility
Some checks failed
Build and Deploy LittleShop / Deploy to Production VPS (Manual Only) (push) Has been skipped
Build and Deploy LittleShop / Deploy to Pre-Production (CT109) (push) Failing after 0s

Issues Fixed:
1. Gitea Actions runner lacks Node.js (required for actions/checkout@v4)
2. Gitea Actions doesn't support actions/upload-artifact@v4
3. Build jobs were unnecessary overhead

Solution:
- Replaced actions/checkout@v4 with native git clone commands
- Removed separate build jobs (build-littleshop, build-telebot)
- Build Docker images directly on deployment targets via SSH
- Simplified workflow: deploy jobs now handle clone + build + deploy

Benefits:
- No Node.js dependency - uses native git/docker only
- Faster deployments - no image transfer overhead
- Simpler pipeline - fewer jobs and steps
- Better resource usage - builds on target server with proper resources

Changes:
- deploy-production: Builds images on VPS from git checkout
- deploy-preproduction: Builds images on CT109 from git checkout
- Removed artifact upload/download steps entirely
- Git clone/checkout happens on deployment targets

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
SysAdmin 2025-11-16 21:08:01 +00:00
parent b04de045c5
commit 8a70e4aad1

View File

@ -14,95 +14,14 @@ env:
COMPOSE_DOCKER_CLI_BUILD: 1 COMPOSE_DOCKER_CLI_BUILD: 1
jobs: jobs:
build-littleshop:
name: Build LittleShop Docker Image
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Build LittleShop image
run: |
echo "Building LittleShop Docker image"
docker build --no-cache -t littleshop:${{ github.sha }} .
docker tag littleshop:${{ github.sha }} littleshop:latest
if [[ "${{ github.ref_type }}" == "tag" ]]; then
echo "Tagging as version ${{ github.ref_name }}"
docker tag littleshop:${{ github.sha }} littleshop:${{ github.ref_name }}
fi
- name: Save LittleShop image
run: |
mkdir -p /tmp/docker-images
docker save littleshop:${{ github.sha }} | gzip > /tmp/docker-images/littleshop.tar.gz
- name: Upload LittleShop artifact
uses: actions/upload-artifact@v4
with:
name: littleshop-image
path: /tmp/docker-images/littleshop.tar.gz
retention-days: 1
build-telebot:
name: Build TeleBot Docker Image
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Build TeleBot image
run: |
echo "Building TeleBot Docker image"
docker build --no-cache -t telebot:${{ github.sha }} -f Dockerfile.telebot .
docker tag telebot:${{ github.sha }} telebot:latest
if [[ "${{ github.ref_type }}" == "tag" ]]; then
echo "Tagging as version ${{ github.ref_name }}"
docker tag telebot:${{ github.sha }} telebot:${{ github.ref_name }}
fi
- name: Save TeleBot image
run: |
mkdir -p /tmp/docker-images
docker save telebot:${{ github.sha }} | gzip > /tmp/docker-images/telebot.tar.gz
- name: Upload TeleBot artifact
uses: actions/upload-artifact@v4
with:
name: telebot-image
path: /tmp/docker-images/telebot.tar.gz
retention-days: 1
deploy-production: deploy-production:
name: Deploy to Production VPS (Manual Only) name: Deploy to Production VPS (Manual Only)
needs: [build-littleshop, build-telebot]
runs-on: ubuntu-latest runs-on: ubuntu-latest
if: false # Disabled - Manual deployment only via workflow_dispatch if: false # Disabled - Manual deployment only via workflow_dispatch
environment: environment:
name: production name: production
url: https://admin.dark.side url: https://admin.dark.side
steps: steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Download LittleShop image
uses: actions/download-artifact@v4
with:
name: littleshop-image
path: /tmp/docker-images
- name: Download TeleBot image
uses: actions/download-artifact@v4
with:
name: telebot-image
path: /tmp/docker-images
- name: Load Docker images
run: |
docker load < /tmp/docker-images/littleshop.tar.gz
docker load < /tmp/docker-images/telebot.tar.gz
- name: Set up SSH - name: Set up SSH
run: | run: |
mkdir -p ~/.ssh mkdir -p ~/.ssh
@ -111,27 +30,30 @@ jobs:
chmod 600 ~/.ssh/deploy_key chmod 600 ~/.ssh/deploy_key
ssh-keyscan -p ${{ secrets.VPS_PORT }} ${{ secrets.VPS_HOST }} >> ~/.ssh/known_hosts 2>/dev/null ssh-keyscan -p ${{ secrets.VPS_PORT }} ${{ secrets.VPS_HOST }} >> ~/.ssh/known_hosts 2>/dev/null
- name: Transfer Docker images to VPS
run: |
echo "Copying LittleShop image to VPS..."
docker save littleshop:${{ github.sha }} | \
ssh -i ~/.ssh/deploy_key -p ${{ secrets.VPS_PORT }} ${{ secrets.VPS_USER }}@${{ secrets.VPS_HOST }} \
"docker load"
echo "Copying TeleBot image to VPS..."
docker save telebot:${{ github.sha }} | \
ssh -i ~/.ssh/deploy_key -p ${{ secrets.VPS_PORT }} ${{ secrets.VPS_USER }}@${{ secrets.VPS_HOST }} \
"docker load"
- name: Deploy to VPS - name: Deploy to VPS
run: | run: |
ssh -i ~/.ssh/deploy_key -p ${{ secrets.VPS_PORT }} ${{ secrets.VPS_USER }}@${{ secrets.VPS_HOST }} bash -s << 'ENDSSH' ssh -i ~/.ssh/deploy_key -p ${{ secrets.VPS_PORT }} ${{ secrets.VPS_USER }}@${{ secrets.VPS_HOST }} bash -s << 'ENDSSH'
set -e set -e
export VERSION="${{ github.sha }}" export VERSION="${{ github.sha }}"
# Tag the images # Navigate to deployment directory
cd /opt/littleshop
# Pull latest code
echo "Pulling latest code from git..."
git fetch origin
git checkout $VERSION || git checkout main
# Build images on VPS
echo "Building LittleShop image..."
docker build --no-cache -t littleshop:$VERSION .
docker tag littleshop:$VERSION littleshop:latest
docker tag littleshop:$VERSION localhost:5000/littleshop:$VERSION docker tag littleshop:$VERSION localhost:5000/littleshop:$VERSION
docker tag littleshop:$VERSION localhost:5000/littleshop:latest docker tag littleshop:$VERSION localhost:5000/littleshop:latest
echo "Building TeleBot image..."
docker build --no-cache -t telebot:$VERSION -f Dockerfile.telebot .
docker tag telebot:$VERSION telebot:latest
docker tag telebot:$VERSION localhost:5000/telebot:$VERSION docker tag telebot:$VERSION localhost:5000/telebot:$VERSION
docker tag telebot:$VERSION localhost:5000/telebot:latest docker tag telebot:$VERSION localhost:5000/telebot:latest
@ -142,9 +64,6 @@ jobs:
docker push localhost:5000/telebot:$VERSION || true docker push localhost:5000/telebot:$VERSION || true
docker push localhost:5000/telebot:latest || true docker push localhost:5000/telebot:latest || true
# Navigate to deployment directory
cd /opt/littleshop
# Force stop all littleshop containers # Force stop all littleshop containers
echo "Stopping all littleshop containers..." echo "Stopping all littleshop containers..."
docker stop $(docker ps -q --filter "name=littleshop") 2>/dev/null || true docker stop $(docker ps -q --filter "name=littleshop") 2>/dev/null || true
@ -232,33 +151,12 @@ jobs:
deploy-preproduction: deploy-preproduction:
name: Deploy to Pre-Production (CT109) name: Deploy to Pre-Production (CT109)
needs: [build-littleshop, build-telebot]
runs-on: ubuntu-latest runs-on: ubuntu-latest
if: github.ref == 'refs/heads/development' || github.ref == 'refs/heads/main' if: github.ref == 'refs/heads/development' || github.ref == 'refs/heads/main'
environment: environment:
name: pre-production name: pre-production
url: http://ct109.local url: http://ct109.local
steps: steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Download LittleShop image
uses: actions/download-artifact@v4
with:
name: littleshop-image
path: /tmp/docker-images
- name: Download TeleBot image
uses: actions/download-artifact@v4
with:
name: telebot-image
path: /tmp/docker-images
- name: Load Docker images
run: |
docker load < /tmp/docker-images/littleshop.tar.gz
docker load < /tmp/docker-images/telebot.tar.gz
- name: Set up SSH for CT109 - name: Set up SSH for CT109
run: | run: |
mkdir -p ~/.ssh mkdir -p ~/.ssh
@ -267,31 +165,33 @@ jobs:
chmod 600 ~/.ssh/deploy_key chmod 600 ~/.ssh/deploy_key
ssh-keyscan -p ${{ secrets.CT109_SSH_PORT }} ${{ secrets.CT109_HOST }} >> ~/.ssh/known_hosts 2>/dev/null ssh-keyscan -p ${{ secrets.CT109_SSH_PORT }} ${{ secrets.CT109_HOST }} >> ~/.ssh/known_hosts 2>/dev/null
- name: Transfer Docker images to CT109
run: |
echo "Copying LittleShop image to CT109..."
docker save littleshop:${{ github.sha }} | \
ssh -i ~/.ssh/deploy_key -p ${{ secrets.CT109_SSH_PORT }} ${{ secrets.CT109_USER }}@${{ secrets.CT109_HOST }} \
"docker load"
echo "Copying TeleBot image to CT109..."
docker save telebot:${{ github.sha }} | \
ssh -i ~/.ssh/deploy_key -p ${{ secrets.CT109_SSH_PORT }} ${{ secrets.CT109_USER }}@${{ secrets.CT109_HOST }} \
"docker load"
- name: Deploy to CT109 - name: Deploy to CT109
run: | run: |
ssh -i ~/.ssh/deploy_key -p ${{ secrets.CT109_SSH_PORT }} ${{ secrets.CT109_USER }}@${{ secrets.CT109_HOST }} bash -s << 'ENDSSH' ssh -i ~/.ssh/deploy_key -p ${{ secrets.CT109_SSH_PORT }} ${{ secrets.CT109_USER }}@${{ secrets.CT109_HOST }} bash -s << 'ENDSSH'
set -e set -e
export VERSION="${{ github.sha }}" export VERSION="${{ github.sha }}"
# Tag the images
docker tag littleshop:$VERSION littleshop:latest
docker tag telebot:$VERSION telebot:latest
# Navigate to deployment directory # Navigate to deployment directory
cd /opt/littleshop || mkdir -p /opt/littleshop && cd /opt/littleshop cd /opt/littleshop || mkdir -p /opt/littleshop && cd /opt/littleshop
# Clone or pull latest code
if [ ! -d .git ]; then
echo "Cloning repository..."
git clone ${{ gitea.repositoryUrl }} .
fi
echo "Pulling latest code from git..."
git fetch origin
git checkout $VERSION || git checkout main
# Build images on CT109
echo "Building LittleShop image..."
docker build --no-cache -t littleshop:$VERSION .
docker tag littleshop:$VERSION littleshop:latest
echo "Building TeleBot image..."
docker build --no-cache -t telebot:$VERSION -f Dockerfile.telebot .
docker tag telebot:$VERSION telebot:latest
# Stop existing containers # Stop existing containers
echo "Stopping existing containers..." echo "Stopping existing containers..."
docker stop littleshop telebot-service 2>/dev/null || true docker stop littleshop telebot-service 2>/dev/null || true