name: Build and Push Docker Container on: push: branches: - main tags: - '*' # reagiert auf jeden Tag-Push workflow_dispatch: jobs: build-and-push: runs-on: ubuntu-latest steps: - name: Checkout repository uses: actions/checkout@v4 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 # --- Logins --- - name: Login to Gitea Registry uses: docker/login-action@v3 with: registry: ${{ vars.DOCKER_REGISTRY_URL }} username: ${{ secrets.DOCKER_REGISTRY_USERNAME }} password: ${{ secrets.ACTION_ACCESS_TOKEN }} - name: Login to Docker Hub uses: docker/login-action@v3 with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - name: Repo owner to lowercase (for Gitea namespace) run: echo "REPO_OWNER_LC=$(echo '${{ gitea.repository_owner }}' | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV # ---------------- BRANCH BUILD (main) ---------------- # 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 with: context: . push: true platforms: linux/amd64 tags: | ${{ vars.DOCKER_REGISTRY_URL }}/${{ env.REPO_OWNER_LC }}/apache-php:latest ${{ secrets.DOCKERHUB_USERNAME }}/apache-php:latest # ---------------- TAG BUILD ---------------- # On tag: Docker Hub : - 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 }}