ci: change workflow to use a secure registry

This commit is contained in:
log101 2025-03-01 06:33:53 +03:00
parent 4e2bd4e267
commit 555665274d

View File

@ -1,25 +1,45 @@
run-name: ${{ gitea.actor }} name: Build and Push Docker Image
run-name: Build triggered by ${{ gitea.actor }}
on: on:
push: push:
branches: branches:
- "main" - main
jobs: jobs:
build: build:
runs-on: ubuntu-latest runs-on: ubuntu-22.04 # Using specific Ubuntu version instead of latest
steps: steps:
- name: Checkout - name: Checkout repository
uses: actions/checkout@v4 uses: actions/checkout@v4
- name: Set up Docker Buildx - name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3 uses: docker/setup-buildx-action@v3
- name: Log in to private registry
uses: docker/login-action@v3
with: with:
buildkitd-config-inline: | registry: registry.acayip.dev
[registry."192.168.88.252:32000"] username: ${{ secrets.REGISTRY_USERNAME }}
http = true 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 - name: Build and push Docker image
uses: docker/build-push-action@v6 uses: docker/build-push-action@v6
with: with:
push: ${{ github.event_name != 'pull_request' }} context: .
tags: 192.168.88.252:32000/log101-blog:latest 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 }}