Compare commits
2 Commits
a588bd36d6
...
c211d2bf9d
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c211d2bf9d | ||
|
|
beb123b144 |
62
.github/workflows/docker-build.yml
vendored
62
.github/workflows/docker-build.yml
vendored
@@ -1,4 +1,4 @@
|
|||||||
name: Build & Push Docker Image
|
name: Build & Push Docker Image to Gitea Registry
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
@@ -12,61 +12,49 @@ jobs:
|
|||||||
build-and-push:
|
build-and-push:
|
||||||
if: ${{ github.server_url == 'https://git.mischlabs.de' }}
|
if: ${{ github.server_url == 'https://git.mischlabs.de' }}
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
defaults:
|
|
||||||
run:
|
|
||||||
shell: sh
|
|
||||||
permissions:
|
|
||||||
contents: read
|
|
||||||
packages: write
|
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Install Docker CLI
|
- name: Install Docker CLI
|
||||||
|
shell: sh
|
||||||
run: |
|
run: |
|
||||||
if command -v docker >/dev/null 2>&1; then
|
if ! command -v docker >/dev/null 2>&1; then
|
||||||
docker --version
|
echo "Docker CLI not found. Installing static binary..."
|
||||||
exit 0
|
if command -v curl >/dev/null 2>&1; then
|
||||||
fi
|
curl -fsSL https://download.docker.com/linux/static/stable/x86_64/docker-26.1.4.tgz | tar -xz -C /usr/local/bin --strip-components=1 docker/docker
|
||||||
|
elif command -v wget >/dev/null 2>&1; then
|
||||||
|
wget -qO- https://download.docker.com/linux/static/stable/x86_64/docker-26.1.4.tgz | tar -xz -C /usr/local/bin --strip-components=1 docker/docker
|
||||||
|
else
|
||||||
|
echo "Neither curl nor wget found! Attempting package manager install..."
|
||||||
if command -v apt-get >/dev/null 2>&1; then
|
if command -v apt-get >/dev/null 2>&1; then
|
||||||
apt-get update
|
apt-get update && apt-get install -y docker.io
|
||||||
apt-get install -y docker.io
|
|
||||||
elif command -v apk >/dev/null 2>&1; then
|
elif command -v apk >/dev/null 2>&1; then
|
||||||
apk add --no-cache docker-cli
|
apk add --no-cache docker-cli
|
||||||
else
|
else
|
||||||
echo "No supported package manager found to install Docker CLI"
|
echo "Cannot install Docker CLI!"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo "Docker CLI already installed."
|
||||||
|
fi
|
||||||
docker --version
|
docker --version
|
||||||
|
|
||||||
- name: Check Docker daemon
|
- name: Log in to Gitea Package Registry
|
||||||
run: docker version
|
shell: sh
|
||||||
|
|
||||||
- name: Log in to package registry
|
|
||||||
env:
|
|
||||||
REGISTRY_USER: ${{ secrets.REGISTRY_USER }}
|
|
||||||
REGISTRY_TOKEN: ${{ secrets.REGISTRY_TOKEN }}
|
|
||||||
run: |
|
run: |
|
||||||
if [ -z "$REGISTRY_USER" ] || [ -z "$REGISTRY_TOKEN" ]; then
|
if [ -z "${{ secrets.REGISTRY_USER }}" ] || [ -z "${{ secrets.REGISTRY_TOKEN }}" ]; then
|
||||||
echo "Missing registry credentials."
|
echo "Missing registry credentials."
|
||||||
echo "Create repository secrets REGISTRY_USER and REGISTRY_TOKEN."
|
echo "Create repository secrets REGISTRY_USER and REGISTRY_TOKEN."
|
||||||
echo "REGISTRY_TOKEN must be a Gitea access token with package write permission."
|
echo "REGISTRY_TOKEN must be a Gitea access token with package write permission."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
echo "${{ secrets.REGISTRY_TOKEN }}" | docker login "${{ env.REGISTRY }}" -u "${{ secrets.REGISTRY_USER }}" --password-stdin
|
||||||
echo "$REGISTRY_TOKEN" | docker login "$REGISTRY" -u "$REGISTRY_USER" --password-stdin
|
|
||||||
|
|
||||||
- name: Set up Docker Buildx
|
|
||||||
uses: docker/setup-buildx-action@v3
|
|
||||||
|
|
||||||
- name: Build and push Docker image
|
- name: Build and push Docker image
|
||||||
uses: docker/build-push-action@v5
|
shell: sh
|
||||||
with:
|
run: |
|
||||||
context: .
|
docker build -t ${{ env.REGISTRY_IMAGE }}:latest -t ${{ env.REGISTRY_IMAGE }}:${{ github.sha }} .
|
||||||
push: true
|
docker push ${{ env.REGISTRY_IMAGE }}:latest
|
||||||
tags: |
|
docker push ${{ env.REGISTRY_IMAGE }}:${{ github.sha }}
|
||||||
${{ env.REGISTRY_IMAGE }}:latest
|
|
||||||
${{ env.REGISTRY_IMAGE }}:${{ github.sha }}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user