chore: update Docker build and release workflow
- Refactored the `docker-build.yml` workflow to improve clarity and maintainability. - Ensured the workflow correctly handles Docker image building and pushing to the Gitea Container Registry upon version tag pushes. - Enhanced the release step to generate release notes based on previous tags, improving release documentation.
This commit is contained in:
@@ -1,88 +1,88 @@
|
||||
name: Docker Build and Release
|
||||
|
||||
on:
|
||||
push:
|
||||
tags: ["v*"]
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
packages: write
|
||||
|
||||
jobs:
|
||||
build-and-push:
|
||||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
tag: ${{ steps.meta.outputs.tag }}
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: https://gitea.com/actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Set image meta
|
||||
id: meta
|
||||
run: |
|
||||
TAG="${GITHUB_REF#refs/tags/}"
|
||||
echo "tag=$TAG" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Set registry host
|
||||
id: registry
|
||||
run: |
|
||||
host="${GITHUB_SERVER_URL#https://}"
|
||||
host="${host#http://}"
|
||||
echo "host=$host" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Check REGISTRY_TOKEN
|
||||
run: |
|
||||
if [ -z "${{ secrets.REGISTRY_TOKEN }}" ]; then
|
||||
echo "::error::REGISTRY_TOKEN secret is not set. Add it in repository or organization settings."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
- name: Login to Gitea Container Registry
|
||||
run: |
|
||||
host="${{ steps.registry.outputs.host }}"
|
||||
echo "${{ secrets.REGISTRY_TOKEN }}" | docker login "$host" -u "${{ github.actor }}" --password-stdin
|
||||
|
||||
- name: Build and push Docker image
|
||||
run: |
|
||||
host="${{ steps.registry.outputs.host }}"
|
||||
repository=$(echo "${{ github.repository }}" | tr '[:upper:]' '[:lower:]')
|
||||
IMAGE="$host/$repository"
|
||||
TAG="${{ steps.meta.outputs.tag }}"
|
||||
docker build -t "$IMAGE:$TAG" -t "$IMAGE:latest" .
|
||||
docker push "$IMAGE:$TAG"
|
||||
docker push "$IMAGE:latest"
|
||||
|
||||
release:
|
||||
runs-on: ubuntu-latest
|
||||
needs: build-and-push
|
||||
permissions:
|
||||
contents: write
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: https://gitea.com/actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Generate release notes
|
||||
id: notes
|
||||
run: |
|
||||
TAG="${{ needs.build-and-push.outputs.tag }}"
|
||||
PREV=""
|
||||
for t in $(git tag -l --sort=-v:refname "v*"); do
|
||||
[ "$t" = "$TAG" ] && continue
|
||||
PREV="$t"
|
||||
break
|
||||
done
|
||||
if [ -n "$PREV" ]; then
|
||||
git log "$PREV..$TAG" --pretty=format:"- %s (%h)" --no-merges > release_notes.md
|
||||
else
|
||||
(git log -1 --pretty=format:"- %s (%h)" 2>/dev/null || echo "Initial release") > release_notes.md
|
||||
fi
|
||||
|
||||
- name: Create Release
|
||||
uses: https://gitea.com/actions/gitea-release-action@v1
|
||||
with:
|
||||
tag_name: ${{ needs.build-and-push.outputs.tag }}
|
||||
body_path: release_notes.md
|
||||
name: Docker Build and Release
|
||||
|
||||
on:
|
||||
push:
|
||||
tags: ["v*"]
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
packages: write
|
||||
|
||||
jobs:
|
||||
build-and-push:
|
||||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
tag: ${{ steps.meta.outputs.tag }}
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: https://gitea.com/actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Set image meta
|
||||
id: meta
|
||||
run: |
|
||||
TAG="${GITHUB_REF#refs/tags/}"
|
||||
echo "tag=$TAG" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Set registry host
|
||||
id: registry
|
||||
run: |
|
||||
host="${GITHUB_SERVER_URL#https://}"
|
||||
host="${host#http://}"
|
||||
echo "host=$host" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Check REGISTRY_TOKEN
|
||||
run: |
|
||||
if [ -z "${{ secrets.REGISTRY_TOKEN }}" ]; then
|
||||
echo "::error::REGISTRY_TOKEN secret is not set. Add it in repository or organization settings."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
- name: Login to Gitea Container Registry
|
||||
run: |
|
||||
host="${{ steps.registry.outputs.host }}"
|
||||
echo "${{ secrets.REGISTRY_TOKEN }}" | docker login "$host" -u "${{ github.actor }}" --password-stdin
|
||||
|
||||
- name: Build and push Docker image
|
||||
run: |
|
||||
host="${{ steps.registry.outputs.host }}"
|
||||
repository=$(echo "${{ github.repository }}" | tr '[:upper:]' '[:lower:]')
|
||||
IMAGE="$host/$repository"
|
||||
TAG="${{ steps.meta.outputs.tag }}"
|
||||
docker build -t "$IMAGE:$TAG" -t "$IMAGE:latest" .
|
||||
docker push "$IMAGE:$TAG"
|
||||
docker push "$IMAGE:latest"
|
||||
|
||||
release:
|
||||
runs-on: ubuntu-latest
|
||||
needs: build-and-push
|
||||
permissions:
|
||||
contents: write
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: https://gitea.com/actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Generate release notes
|
||||
id: notes
|
||||
run: |
|
||||
TAG="${{ needs.build-and-push.outputs.tag }}"
|
||||
PREV=""
|
||||
for t in $(git tag -l --sort=-v:refname "v*"); do
|
||||
[ "$t" = "$TAG" ] && continue
|
||||
PREV="$t"
|
||||
break
|
||||
done
|
||||
if [ -n "$PREV" ]; then
|
||||
git log "$PREV..$TAG" --pretty=format:"- %s (%h)" --no-merges > release_notes.md
|
||||
else
|
||||
(git log -1 --pretty=format:"- %s (%h)" 2>/dev/null || echo "Initial release") > release_notes.md
|
||||
fi
|
||||
|
||||
- name: Create Release
|
||||
uses: https://gitea.com/actions/gitea-release-action@v1
|
||||
with:
|
||||
tag_name: ${{ needs.build-and-push.outputs.tag }}
|
||||
body_path: release_notes.md
|
||||
|
||||
@@ -290,18 +290,20 @@
|
||||
cell.className = "day" + (isOther ? " other-month" : "") + (isToday ? " today" : "") + (showMarkers && hasAny ? " has-duty" : "") + (showMarkers && hasEvent ? " holiday" : "");
|
||||
|
||||
function namesAttr(list) { return list.length ? escapeHtml(list.map(function (x) { return x.full_name; }).join("\n")) : ""; }
|
||||
function titleAttr(list) { return list.length ? escapeHtml(list.map(function (x) { return x.full_name; }).join(", ")) : ""; }
|
||||
var dutyItemsJson = dutyList.length
|
||||
? JSON.stringify(dutyList.map(function (x) { return { full_name: x.full_name, start_at: x.start_at, end_at: x.end_at }; })).replace(/'/g, "'")
|
||||
: "";
|
||||
|
||||
let html = "<span class=\"num\">" + d.getDate() + "</span><div class=\"day-markers\">";
|
||||
if (showMarkers) {
|
||||
if (dutyList.length) {
|
||||
html += "<button type=\"button\" class=\"duty-marker\" data-event-type=\"duty\" data-names=\"" + namesAttr(dutyList) + "\" title=\"" + titleAttr(dutyList) + "\" aria-label=\"Дежурные\">Д</button>";
|
||||
html += "<button type=\"button\" class=\"duty-marker\" data-event-type=\"duty\" data-date=\"" + escapeHtml(key) + "\" data-names=\"" + namesAttr(dutyList) + "\" data-duty-items='" + dutyItemsJson + "' aria-label=\"Дежурные\">Д</button>";
|
||||
}
|
||||
if (unavailableList.length) {
|
||||
html += "<button type=\"button\" class=\"unavailable-marker\" data-event-type=\"unavailable\" data-names=\"" + namesAttr(unavailableList) + "\" title=\"" + titleAttr(unavailableList) + "\" aria-label=\"Недоступен\">Н</button>";
|
||||
html += "<button type=\"button\" class=\"unavailable-marker\" data-event-type=\"unavailable\" data-names=\"" + namesAttr(unavailableList) + "\" aria-label=\"Недоступен\">Н</button>";
|
||||
}
|
||||
if (vacationList.length) {
|
||||
html += "<button type=\"button\" class=\"vacation-marker\" data-event-type=\"vacation\" data-names=\"" + namesAttr(vacationList) + "\" title=\"" + titleAttr(vacationList) + "\" aria-label=\"Отпуск\">О</button>";
|
||||
html += "<button type=\"button\" class=\"vacation-marker\" data-event-type=\"vacation\" data-names=\"" + namesAttr(vacationList) + "\" aria-label=\"Отпуск\">О</button>";
|
||||
}
|
||||
if (hasEvent) {
|
||||
html += "<button type=\"button\" class=\"info-btn\" aria-label=\"Информация о дне\" data-summary=\"" + escapeHtml(eventSummaries.join("\n")) + "\">i</button>";
|
||||
@@ -403,11 +405,61 @@
|
||||
|
||||
var EVENT_TYPE_LABELS = { duty: "Дежурство", unavailable: "Недоступен", vacation: "Отпуск" };
|
||||
|
||||
function formatHHMM(isoStr) {
|
||||
if (!isoStr) { return ""; }
|
||||
var d = new Date(isoStr);
|
||||
var h = d.getHours();
|
||||
var m = d.getMinutes();
|
||||
return (h < 10 ? "0" : "") + h + ":" + (m < 10 ? "0" : "") + m;
|
||||
}
|
||||
|
||||
function getDutyMarkerHintContent(marker) {
|
||||
var type = marker.getAttribute("data-event-type") || "duty";
|
||||
var label = EVENT_TYPE_LABELS[type] || type;
|
||||
var names = (marker.getAttribute("data-names") || "").replace(/\n/g, ", ");
|
||||
return names ? label + ": " + names : label;
|
||||
var names = marker.getAttribute("data-names") || "";
|
||||
var body;
|
||||
if (type === "duty") {
|
||||
var dutyItemsRaw = marker.getAttribute("data-duty-items") || (marker.dataset && marker.dataset.dutyItems) || "";
|
||||
var dutyItems = [];
|
||||
try {
|
||||
if (dutyItemsRaw) { dutyItems = JSON.parse(dutyItemsRaw); }
|
||||
} catch (e) { /* ignore */ }
|
||||
var hasTimes = dutyItems.length > 0 && dutyItems.some(function (it) {
|
||||
var start = it.start_at != null ? it.start_at : it.startAt;
|
||||
var end = it.end_at != null ? it.end_at : it.endAt;
|
||||
return start || end;
|
||||
});
|
||||
if (dutyItems.length >= 1 && hasTimes) {
|
||||
var hintDay = marker.getAttribute("data-date") || "";
|
||||
body = dutyItems.map(function (item, idx) {
|
||||
var startAt = item.start_at != null ? item.start_at : item.startAt;
|
||||
var endAt = item.end_at != null ? item.end_at : item.endAt;
|
||||
var endHHMM = endAt ? formatHHMM(endAt) : "";
|
||||
var startHHMM = startAt ? formatHHMM(startAt) : "";
|
||||
var startSameDay = hintDay && startAt && localDateString(new Date(startAt)) === hintDay;
|
||||
var endSameDay = hintDay && endAt && localDateString(new Date(endAt)) === hintDay;
|
||||
var fullName = item.full_name != null ? item.full_name : item.fullName;
|
||||
var parts = [fullName];
|
||||
if (idx === 0) {
|
||||
if (startSameDay && startHHMM) {
|
||||
parts.push("с " + startHHMM);
|
||||
if (endSameDay && endHHMM && endHHMM !== startHHMM) { parts.push("до " + endHHMM); }
|
||||
} else if (endHHMM) {
|
||||
parts.push("до " + endHHMM);
|
||||
}
|
||||
} else if (idx > 0) {
|
||||
if (startHHMM) { parts.push("с " + startHHMM); }
|
||||
if (endHHMM && endSameDay && endHHMM !== startHHMM) { parts.push("до " + endHHMM); }
|
||||
}
|
||||
return parts.join(", ");
|
||||
}).join("\n");
|
||||
} else {
|
||||
body = names;
|
||||
}
|
||||
} else {
|
||||
body = names;
|
||||
}
|
||||
return body ? label + ":\n" + body : label;
|
||||
}
|
||||
|
||||
function clearActiveDutyMarker() {
|
||||
@@ -568,7 +620,7 @@
|
||||
const dayClass = "duty-timeline-day" + (isToday ? " duty-timeline-day--today" : "");
|
||||
const dateLabel = isToday ? dateKeyToDDMM(date) : dateKeyToDDMM(date);
|
||||
const dateCellHtml = isToday
|
||||
? "<span class=\"duty-timeline-date\"><span class=\"duty-timeline-date-label\">Сегодня</span><span class=\"duty-timeline-date-dot\" aria-hidden=\"true\"></span><span class=\"duty-timeline-date-day\">" + escapeHtml(dateLabel) + "</span></span>"
|
||||
? "<span class=\"duty-timeline-date\"><span class=\"duty-timeline-date-label\">Сегодня</span><span class=\"duty-timeline-date-day\">" + escapeHtml(dateLabel) + "</span><span class=\"duty-timeline-date-dot\" aria-hidden=\"true\"></span></span>"
|
||||
: "<span class=\"duty-timeline-date\">" + escapeHtml(dateLabel) + "</span>";
|
||||
const dayDuties = duties.filter(function (d) { return localDateString(new Date(d.start_at)) === date; }).sort(function (a, b) { return new Date(a.start_at) - new Date(b.start_at); });
|
||||
let dayHtml = "";
|
||||
|
||||
Reference in New Issue
Block a user