From 9363f50fdd066a211d9c9a150924b83357cd41ed Mon Sep 17 00:00:00 2001 From: Pat Teruel Date: Tue, 30 Dec 2025 23:25:03 +0800 Subject: [PATCH] ci: simplify workflows to use docker CLI only - remove Node-based actions (checkout, buildx, login, build-push) - rely on gitea workspace checkout and plain docker commands - avoid Node requirement on self-hosted runner --- .gitea/workflows/build.yml | 74 +++++++++--------------------- .gitea/workflows/pr-validation.yml | 23 +--------- 2 files changed, 23 insertions(+), 74 deletions(-) diff --git a/.gitea/workflows/build.yml b/.gitea/workflows/build.yml index 091ef83..c541286 100644 --- a/.gitea/workflows/build.yml +++ b/.gitea/workflows/build.yml @@ -13,56 +13,26 @@ jobs: build: runs-on: linux steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - + - name: Build Docker image + run: | + echo "Building Docker image..." + docker build -t karaokepedia:latest . + docker tag karaokepedia:latest karaokepedia:${{ github.sha }} + echo "✅ Image built successfully" + - name: Log in to Docker Hub - uses: docker/login-action@v3 - with: - username: ${{ secrets.DOCKER_USERNAME }} - password: ${{ secrets.DOCKER_PASSWORD }} - - # Uncomment if using GitHub Container Registry - # - name: Log in to GitHub Container Registry - # uses: docker/login-action@v3 - # with: - # registry: ghcr.io - # username: ${{ github.actor }} - # password: ${{ secrets.GITHUB_TOKEN }} - - # Uncomment if using Gitea Container Registry - # - name: Log in to Gitea Container Registry - # uses: docker/login-action@v3 - # with: - # registry: gitea.yourdomain.com - # username: ${{ secrets.GITEA_USERNAME }} - # password: ${{ secrets.GITEA_PASSWORD }} - - - name: Extract metadata - id: meta - uses: docker/metadata-action@v5 - with: - images: ${{ secrets.DOCKER_USERNAME }}/${{ env.IMAGE_NAME }} - # Use this for GHCR: - # images: ghcr.io/${{ github.repository_owner }}/${{ env.IMAGE_NAME }} - # Use this for Gitea: - # images: gitea.yourdomain.com/${{ github.repository_owner }}/${{ env.IMAGE_NAME }} - tags: | - type=raw,value=latest - type=sha,prefix={{branch}}- - - - name: Build and push Docker image - uses: docker/build-push-action@v5 - with: - context: . - push: true - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} - cache-from: type=gha - cache-to: type=gha,mode=max - - - name: Image digest - run: echo ${{ steps.meta.outputs.digest }} + run: | + echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u "${{ secrets.DOCKER_USERNAME }}" --password-stdin + + - name: Push Docker image + run: | + # Push with registry prefix if secrets are configured + if [ -n "${{ secrets.DOCKER_USERNAME }}" ]; then + docker tag karaokepedia:latest ${{ secrets.DOCKER_USERNAME }}/${{ env.IMAGE_NAME }}:latest + docker tag karaokepedia:latest ${{ secrets.DOCKER_USERNAME }}/${{ env.IMAGE_NAME }}:main-${{ github.sha }} + docker push ${{ secrets.DOCKER_USERNAME }}/${{ env.IMAGE_NAME }}:latest + docker push ${{ secrets.DOCKER_USERNAME }}/${{ env.IMAGE_NAME }}:main-${{ github.sha }} + echo "✅ Pushed to Docker Hub: ${{ secrets.DOCKER_USERNAME }}/${{ env.IMAGE_NAME }}" + else + echo "⚠️ Docker Hub credentials not configured, skipping push" + fi diff --git a/.gitea/workflows/pr-validation.yml b/.gitea/workflows/pr-validation.yml index 19bb62c..a0303bc 100644 --- a/.gitea/workflows/pr-validation.yml +++ b/.gitea/workflows/pr-validation.yml @@ -49,9 +49,6 @@ jobs: validate-docker: runs-on: linux steps: - - name: Checkout code - uses: actions/checkout@v4 - - name: Validate Dockerfile syntax run: | if [ -f "Dockerfile" ]; then @@ -86,22 +83,7 @@ jobs: build-test: runs-on: linux steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - - - name: Build Docker image (no push) - uses: docker/build-push-action@v5 - with: - context: . - push: false - tags: karaokepedia:pr-${{ github.event.pull_request.number }} - cache-from: type=gha - cache-to: type=gha,mode=max - - - name: Test container starts + - name: Build and test Docker image run: | docker build -t karaokepedia:test . CONTAINER_ID=$(docker run -d -p 8080:80 karaokepedia:test) @@ -145,9 +127,6 @@ jobs: check-files: runs-on: linux steps: - - name: Checkout code - uses: actions/checkout@v4 - - name: Check required files exist run: | REQUIRED_FILES=(