Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions .github/workflows/docker-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ name: Build & Push Docker Image
on:
push:
branches: [ "main", "dev" ]
tags: [ "v*" ]

jobs:
build:
Expand All @@ -16,10 +17,18 @@ jobs:
- name: Checkout
uses: actions/checkout@v4

- name: Set variables (safe + lowercase)
- name: Set variables (safe + lowercase + tag/branch aware)
run: |
REPO="${GITHUB_REPOSITORY,,}"
TAG="${GITHUB_REF_NAME}"

# detect tag vs branch
if [[ "${GITHUB_REF_TYPE}" == "tag" ]]; then
TAG="${GITHUB_REF_NAME}"
else
TAG="${GITHUB_REF_NAME}"
fi

# lowercase safety
TAG=$(echo "$TAG" | tr '[:upper:]' '[:lower:]')

echo "REPO=$REPO" >> $GITHUB_ENV
Expand All @@ -29,6 +38,7 @@ jobs:
run: |
echo "Repo: $REPO"
echo "Tag: $TAG"
echo "Ref type: $GITHUB_REF_TYPE"

- name: Login to GHCR
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
Expand Down
41 changes: 39 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,39 @@
# project_template_ghcr
This is a simple project template for utilizing ghcr on first pull.
# 🚀 GitHub Actions Docker Template

A lightweight DevOps starter template for containerized services using GitHub Actions, Docker, and GitHub Container Registry (GHCR).

This template is designed to eliminate manual server builds and provide a fully automated CI/CD pipeline for modern service deployment.

---

## 🧱 Features

- ⚡ Automated CI/CD via GitHub Actions
- 🐳 Docker-based deployment
- 📦 Container publishing to GitHub Container Registry (GHCR)
- 🌿 Branch-based environments (`dev`, `latest-stable`)
- 🔁 Automatic image tagging based on branch name
- 🖥️ Server-only runtime (no build required on host)
- ♻️ Fully reusable template for multiple services

---

## 🌿 Branch Strategy

| Branch | Purpose | Image Tag |
|----------------|--------------------|------------------|
| `dev` | Development | `dev` |
| `main` | Stable production | `main` |
| `v*` (tags) | Releases | `v1.0.0`, etc. |

---

## 🚀 How to Use This Template

1. Click **"Use this template"** on GitHub
2. Create a new repository
3. Clone your new repo:

```bash id="clone1"
git clone https://github.com/TheMux-42/github-actions-docker-template.git
cd github-actions-docker-template
Loading