This commit is contained in:
Grzegorz Matoga
2025-07-24 22:37:41 +02:00
parent f9c4384c71
commit 672514b544

View File

@@ -1,33 +1,46 @@
name: Build and Push Docker Image name: Docker Build and Push Demo
run-name: ${{ gitea.actor }} is building a Docker image 🐳
on: on: [push]
push:
branches: [ main ]
jobs: jobs:
build: Build-Docker-Image:
runs-on: runner runs-on: ubuntu-latest
container: docker:24-git
steps: steps:
- name: Clone repository - run: echo "🎉 The job was automatically triggered by a ${{ gitea.event_name }} event."
run: | - run: echo "🐧 This job is now running on a ${{ runner.os }} server hosted by Gitea!"
# Remove the https:// prefix since gitea.server_url already includes it - run: echo "🔎 The name of your branch is ${{ gitea.ref }} and your repository is ${{ gitea.repository }}."
git clone ${{ gitea.server_url }}/${{ gitea.repository }}.git .
git checkout ${{ gitea.sha }}
env:
GIT_ASKPASS: /bin/echo
GIT_USERNAME: ${{ gitea.actor }}
GIT_PASSWORD: ${{ secrets.GITEATOKEN }}
- name: Build and push - name: Check out repository code
uses: actions/checkout@v4
- run: echo "💡 The ${{ gitea.repository }} repository has been cloned to the runner."
- name: List files in the repository
run: | run: |
# Login to registry echo "📁 Repository contents:"
echo "${{ secrets.GITEATOKEN }}" | docker login "${{ gitea.server_url }}" -u "${{ gitea.actor }}" --password-stdin ls -la ${{ gitea.workspace }}
# Build with correct image format - name: Set up Docker Buildx
IMAGE_NAME="git.eurekin.pl/${{ gitea.repository_owner }}/hello-gitea" uses: docker/setup-buildx-action@v3
IMAGE_NAME=$(echo "$IMAGE_NAME" | tr '[:upper:]' '[:lower:]')
- name: Login to Gitea Container Registry
echo "Building image: $IMAGE_NAME:latest" uses: docker/login-action@v3
docker build -t "${IMAGE_NAME}:latest" . with:
docker push "${IMAGE_NAME}:latest" registry: ${{ gitea.server_url }}
username: ${{ gitea.actor }}
password: ${{ secrets.GITEATOKEN }}
- run: echo "🔨 Building Docker image..."
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: |
git.eurekin.pl/${{ gitea.repository_owner }}/hello-gitea:latest
git.eurekin.pl/${{ gitea.repository_owner }}/hello-gitea:${{ gitea.sha }}
- run: echo "📦 Docker image has been pushed to the registry!"
- run: echo "🎯 You can pull it with: docker pull git.eurekin.pl/${{ gitea.repository_owner }}/hello-gitea:latest"
- run: echo "🍏 This job's status is ${{ job.status }}."