From 555665274d5831fa5a74ed55d422f58ada341698 Mon Sep 17 00:00:00 2001 From: log101 Date: Sat, 1 Mar 2025 06:33:53 +0300 Subject: [PATCH] ci: change workflow to use a secure registry --- .gitea/workflows/static-deploy.yml | 38 +++++++++++++++++++++++------- 1 file changed, 29 insertions(+), 9 deletions(-) diff --git a/.gitea/workflows/static-deploy.yml b/.gitea/workflows/static-deploy.yml index df069f1..3adcd3d 100644 --- a/.gitea/workflows/static-deploy.yml +++ b/.gitea/workflows/static-deploy.yml @@ -1,25 +1,45 @@ -run-name: ${{ gitea.actor }} +name: Build and Push Docker Image +run-name: Build triggered by ${{ gitea.actor }} + on: push: branches: - - "main" + - main jobs: build: - runs-on: ubuntu-latest + runs-on: ubuntu-22.04 # Using specific Ubuntu version instead of latest steps: - - name: Checkout + - name: Checkout repository uses: actions/checkout@v4 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 + + - name: Log in to private registry + uses: docker/login-action@v3 with: - buildkitd-config-inline: | - [registry."192.168.88.252:32000"] - http = true + registry: registry.acayip.dev + username: ${{ secrets.REGISTRY_USERNAME }} + password: ${{ secrets.REGISTRY_PASSWORD }} + + - name: Generate image tag + id: meta + run: | + VERSION=$(date +%Y%m%d)-$(git rev-parse --short HEAD) + echo "TAG=registry.log101.dev/log101-dot-dev:${VERSION}" >> $GITHUB_OUTPUT - name: Build and push Docker image uses: docker/build-push-action@v6 with: - push: ${{ github.event_name != 'pull_request' }} - tags: 192.168.88.252:32000/log101-blog:latest + context: . + push: ${{ gitea.event_name != 'pull_request' }} + tags: ${{ steps.meta.outputs.TAG }} + # Add build caching for faster builds + cache-from: type=registry,ref=registry.log101.dev/log101-dot-dev:buildcache + cache-to: type=registry,ref=registry.log101.dev/log101-dot-dev:buildcache,mode=max + # Add labels for better tracking + labels: | + org.opencontainers.image.source=${{ gitea.repository }} + org.opencontainers.image.revision=${{ gitea.sha }} + org.opencontainers.image.created=${{ gitea.event.created_at }}