This commit is contained in:
@@ -1,8 +1,11 @@
|
|||||||
name: Build and Push Docker Container
|
name: Build and Push Docker Container
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- main
|
- main
|
||||||
|
tags:
|
||||||
|
- '*' # reagiert auf jeden Tag-Push
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
@@ -16,15 +19,7 @@ jobs:
|
|||||||
- name: Set up Docker Buildx
|
- name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v3
|
uses: docker/setup-buildx-action@v3
|
||||||
|
|
||||||
# --- Extract Version Tag or Commit SHA ---
|
# --- Logins ---
|
||||||
- name: Determine version tag
|
|
||||||
id: version
|
|
||||||
run: |
|
|
||||||
TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "")
|
|
||||||
echo "VERSION_TAG=$TAG" >> $GITHUB_ENV
|
|
||||||
echo "Using version tag: $TAG"
|
|
||||||
|
|
||||||
# --- Login to Gitea Registry ---
|
|
||||||
- name: Login to Gitea Registry
|
- name: Login to Gitea Registry
|
||||||
uses: docker/login-action@v3
|
uses: docker/login-action@v3
|
||||||
with:
|
with:
|
||||||
@@ -32,18 +27,19 @@ jobs:
|
|||||||
username: ${{ secrets.DOCKER_REGISTRY_USERNAME }}
|
username: ${{ secrets.DOCKER_REGISTRY_USERNAME }}
|
||||||
password: ${{ secrets.ACTION_ACCESS_TOKEN }}
|
password: ${{ secrets.ACTION_ACCESS_TOKEN }}
|
||||||
|
|
||||||
# --- Login to Docker Hub ---
|
|
||||||
- name: Login to Docker Hub
|
- name: Login to Docker Hub
|
||||||
uses: docker/login-action@v3
|
uses: docker/login-action@v3
|
||||||
with:
|
with:
|
||||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||||
|
|
||||||
- name: Convert repository owner to lowercase
|
- name: Repo owner to lowercase (for Gitea namespace)
|
||||||
run: echo "REPO_OWNER_LC=$(echo '${{ gitea.repository_owner }}' | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV
|
run: echo "REPO_OWNER_LC=$(echo '${{ gitea.repository_owner }}' | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV
|
||||||
|
|
||||||
# --- Build and Push to Both Registries ---
|
# ---------------- BRANCH BUILD (main) ----------------
|
||||||
- name: Build and push Docker image
|
# On Branch: Gitea and Docker Hub :latest
|
||||||
|
- name: Build & push (branch -> only :latest everywhere)
|
||||||
|
if: ${{ github.ref_type == 'branch' && github.ref == 'refs/heads/main' }}
|
||||||
uses: docker/build-push-action@v6
|
uses: docker/build-push-action@v6
|
||||||
with:
|
with:
|
||||||
context: .
|
context: .
|
||||||
@@ -52,4 +48,14 @@ jobs:
|
|||||||
tags: |
|
tags: |
|
||||||
${{ vars.DOCKER_REGISTRY_URL }}/${{ env.REPO_OWNER_LC }}/apache-php:latest
|
${{ vars.DOCKER_REGISTRY_URL }}/${{ env.REPO_OWNER_LC }}/apache-php:latest
|
||||||
${{ secrets.DOCKERHUB_USERNAME }}/apache-php:latest
|
${{ secrets.DOCKERHUB_USERNAME }}/apache-php:latest
|
||||||
${{ secrets.DOCKERHUB_USERNAME }}/apache-php:${{ env.VERSION_TAG }}
|
|
||||||
|
# ---------------- TAG BUILD ----------------
|
||||||
|
# On tag: Docker Hub :<tag>
|
||||||
|
- name: Build & push (tag -> tag on Docker Hub)
|
||||||
|
if: ${{ github.ref_type == 'tag' }}
|
||||||
|
uses: docker/build-push-action@v6
|
||||||
|
with:
|
||||||
|
context: .
|
||||||
|
push: true
|
||||||
|
platforms: linux/amd64
|
||||||
|
tags: ${{ secrets.DOCKERHUB_USERNAME }}/apache-php:${{ github.ref_name }}
|
||||||
|
|||||||
Reference in New Issue
Block a user