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:
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 }}