47 lines
1.8 KiB
YAML
47 lines
1.8 KiB
YAML
name: Build and Push to Gitea Registry
|
|
on: [push]
|
|
|
|
jobs:
|
|
build-and-push:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v3
|
|
with:
|
|
# If your Gitea instance uses HTTP (not HTTPS), add this
|
|
config-inline: |
|
|
[registry."${{ gitea.server_url }}"]
|
|
http = true
|
|
insecure = true
|
|
|
|
# Login to Docker Hub for pulling base images
|
|
- name: Login to Docker Hub
|
|
uses: docker/login-action@v3
|
|
with:
|
|
username: ${{ secrets.DOCKER_USERNAME }}
|
|
password: ${{ secrets.DOCKER_PASSWORD }}
|
|
|
|
# Login to Gitea Registry for pushing
|
|
- name: Login to Gitea Registry
|
|
uses: docker/login-action@v3
|
|
with:
|
|
registry: ${{ gitea.server_url }} # e.g., gitea.example.com or 192.168.1.100:3000
|
|
username: ${{ gitea.repository_owner }}
|
|
password: ${{ secrets.GITEA_TOKEN }}
|
|
|
|
- name: Build and push to Gitea Registry
|
|
uses: docker/build-push-action@v5
|
|
with:
|
|
context: .
|
|
push: true
|
|
# Pull base images from Docker Hub (automatically authenticated)
|
|
# Push final image to Gitea Registry
|
|
tags: |
|
|
${{ gitea.server_url }}/${{ gitea.repository_owner }}/kulakpos_web:latest
|
|
${{ gitea.server_url }}/${{ gitea.repository_owner }}/kulakpos_web:${{ github.sha }}
|
|
# Optional: Add cache from Docker Hub to speed up builds
|
|
cache-from: type=registry,ref=${{ secrets.DOCKER_USERNAME }}/kulakpos_web:buildcache
|
|
cache-to: type=registry,ref=${{ gitea.server_url }}/${{ gitea.repository_owner }}/kulakpos_web:buildcache,mode=max |