wip
This commit is contained in:
@@ -1,33 +1,46 @@
|
||||
name: Build and Push Docker Image
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ main ]
|
||||
name: Docker Build and Push Demo
|
||||
run-name: ${{ gitea.actor }} is building a Docker image 🐳
|
||||
on: [push]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: runner
|
||||
container: docker:24-git
|
||||
Build-Docker-Image:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Clone repository
|
||||
run: |
|
||||
# Remove the https:// prefix since gitea.server_url already includes it
|
||||
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 }}
|
||||
- run: echo "🎉 The job was automatically triggered by a ${{ gitea.event_name }} event."
|
||||
- run: echo "🐧 This job is now running on a ${{ runner.os }} server hosted by Gitea!"
|
||||
- run: echo "🔎 The name of your branch is ${{ gitea.ref }} and your repository is ${{ gitea.repository }}."
|
||||
|
||||
- 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: |
|
||||
# Login to registry
|
||||
echo "${{ secrets.GITEATOKEN }}" | docker login "${{ gitea.server_url }}" -u "${{ gitea.actor }}" --password-stdin
|
||||
|
||||
# Build with correct image format
|
||||
IMAGE_NAME="git.eurekin.pl/${{ gitea.repository_owner }}/hello-gitea"
|
||||
IMAGE_NAME=$(echo "$IMAGE_NAME" | tr '[:upper:]' '[:lower:]')
|
||||
|
||||
echo "Building image: $IMAGE_NAME:latest"
|
||||
docker build -t "${IMAGE_NAME}:latest" .
|
||||
docker push "${IMAGE_NAME}:latest"
|
||||
echo "📁 Repository contents:"
|
||||
ls -la ${{ gitea.workspace }}
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
- name: Login to Gitea Container Registry
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
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 }}."
|
||||
Reference in New Issue
Block a user