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
|
name: Docker Build and Release
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
tags: ["v*"]
|
tags: ["v*"]
|
||||||
|
|
||||||
permissions:
|
permissions:
|
||||||
contents: read
|
contents: read
|
||||||
packages: write
|
packages: write
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build-and-push:
|
build-and-push:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
outputs:
|
outputs:
|
||||||
tag: ${{ steps.meta.outputs.tag }}
|
tag: ${{ steps.meta.outputs.tag }}
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: https://gitea.com/actions/checkout@v4
|
uses: https://gitea.com/actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
|
|
||||||
- name: Set image meta
|
- name: Set image meta
|
||||||
id: meta
|
id: meta
|
||||||
run: |
|
run: |
|
||||||
TAG="${GITHUB_REF#refs/tags/}"
|
TAG="${GITHUB_REF#refs/tags/}"
|
||||||
echo "tag=$TAG" >> $GITHUB_OUTPUT
|
echo "tag=$TAG" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
- name: Set registry host
|
- name: Set registry host
|
||||||
id: registry
|
id: registry
|
||||||
run: |
|
run: |
|
||||||
host="${GITHUB_SERVER_URL#https://}"
|
host="${GITHUB_SERVER_URL#https://}"
|
||||||
host="${host#http://}"
|
host="${host#http://}"
|
||||||
echo "host=$host" >> $GITHUB_OUTPUT
|
echo "host=$host" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
- name: Check REGISTRY_TOKEN
|
- name: Check REGISTRY_TOKEN
|
||||||
run: |
|
run: |
|
||||||
if [ -z "${{ secrets.REGISTRY_TOKEN }}" ]; then
|
if [ -z "${{ secrets.REGISTRY_TOKEN }}" ]; then
|
||||||
echo "::error::REGISTRY_TOKEN secret is not set. Add it in repository or organization settings."
|
echo "::error::REGISTRY_TOKEN secret is not set. Add it in repository or organization settings."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
- name: Login to Gitea Container Registry
|
- name: Login to Gitea Container Registry
|
||||||
run: |
|
run: |
|
||||||
host="${{ steps.registry.outputs.host }}"
|
host="${{ steps.registry.outputs.host }}"
|
||||||
echo "${{ secrets.REGISTRY_TOKEN }}" | docker login "$host" -u "${{ github.actor }}" --password-stdin
|
echo "${{ secrets.REGISTRY_TOKEN }}" | docker login "$host" -u "${{ github.actor }}" --password-stdin
|
||||||
|
|
||||||
- name: Build and push Docker image
|
- name: Build and push Docker image
|
||||||
run: |
|
run: |
|
||||||
host="${{ steps.registry.outputs.host }}"
|
host="${{ steps.registry.outputs.host }}"
|
||||||
repository=$(echo "${{ github.repository }}" | tr '[:upper:]' '[:lower:]')
|
repository=$(echo "${{ github.repository }}" | tr '[:upper:]' '[:lower:]')
|
||||||
IMAGE="$host/$repository"
|
IMAGE="$host/$repository"
|
||||||
TAG="${{ steps.meta.outputs.tag }}"
|
TAG="${{ steps.meta.outputs.tag }}"
|
||||||
docker build -t "$IMAGE:$TAG" -t "$IMAGE:latest" .
|
docker build -t "$IMAGE:$TAG" -t "$IMAGE:latest" .
|
||||||
docker push "$IMAGE:$TAG"
|
docker push "$IMAGE:$TAG"
|
||||||
docker push "$IMAGE:latest"
|
docker push "$IMAGE:latest"
|
||||||
|
|
||||||
release:
|
release:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
needs: build-and-push
|
needs: build-and-push
|
||||||
permissions:
|
permissions:
|
||||||
contents: write
|
contents: write
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: https://gitea.com/actions/checkout@v4
|
uses: https://gitea.com/actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
|
|
||||||
- name: Generate release notes
|
- name: Generate release notes
|
||||||
id: notes
|
id: notes
|
||||||
run: |
|
run: |
|
||||||
TAG="${{ needs.build-and-push.outputs.tag }}"
|
TAG="${{ needs.build-and-push.outputs.tag }}"
|
||||||
PREV=""
|
PREV=""
|
||||||
for t in $(git tag -l --sort=-v:refname "v*"); do
|
for t in $(git tag -l --sort=-v:refname "v*"); do
|
||||||
[ "$t" = "$TAG" ] && continue
|
[ "$t" = "$TAG" ] && continue
|
||||||
PREV="$t"
|
PREV="$t"
|
||||||
break
|
break
|
||||||
done
|
done
|
||||||
if [ -n "$PREV" ]; then
|
if [ -n "$PREV" ]; then
|
||||||
git log "$PREV..$TAG" --pretty=format:"- %s (%h)" --no-merges > release_notes.md
|
git log "$PREV..$TAG" --pretty=format:"- %s (%h)" --no-merges > release_notes.md
|
||||||
else
|
else
|
||||||
(git log -1 --pretty=format:"- %s (%h)" 2>/dev/null || echo "Initial release") > release_notes.md
|
(git log -1 --pretty=format:"- %s (%h)" 2>/dev/null || echo "Initial release") > release_notes.md
|
||||||
fi
|
fi
|
||||||
|
|
||||||
- name: Create Release
|
- name: Create Release
|
||||||
uses: https://gitea.com/actions/gitea-release-action@v1
|
uses: https://gitea.com/actions/gitea-release-action@v1
|
||||||
with:
|
with:
|
||||||
tag_name: ${{ needs.build-and-push.outputs.tag }}
|
tag_name: ${{ needs.build-and-push.outputs.tag }}
|
||||||
body_path: release_notes.md
|
body_path: release_notes.md
|
||||||
|
|||||||
@@ -290,18 +290,20 @@
|
|||||||
cell.className = "day" + (isOther ? " other-month" : "") + (isToday ? " today" : "") + (showMarkers && hasAny ? " has-duty" : "") + (showMarkers && hasEvent ? " holiday" : "");
|
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 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\">";
|
let html = "<span class=\"num\">" + d.getDate() + "</span><div class=\"day-markers\">";
|
||||||
if (showMarkers) {
|
if (showMarkers) {
|
||||||
if (dutyList.length) {
|
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) {
|
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) {
|
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) {
|
if (hasEvent) {
|
||||||
html += "<button type=\"button\" class=\"info-btn\" aria-label=\"Информация о дне\" data-summary=\"" + escapeHtml(eventSummaries.join("\n")) + "\">i</button>";
|
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: "Отпуск" };
|
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) {
|
function getDutyMarkerHintContent(marker) {
|
||||||
var type = marker.getAttribute("data-event-type") || "duty";
|
var type = marker.getAttribute("data-event-type") || "duty";
|
||||||
var label = EVENT_TYPE_LABELS[type] || type;
|
var label = EVENT_TYPE_LABELS[type] || type;
|
||||||
var names = (marker.getAttribute("data-names") || "").replace(/\n/g, ", ");
|
var names = marker.getAttribute("data-names") || "";
|
||||||
return names ? label + ": " + names : label;
|
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() {
|
function clearActiveDutyMarker() {
|
||||||
@@ -568,7 +620,7 @@
|
|||||||
const dayClass = "duty-timeline-day" + (isToday ? " duty-timeline-day--today" : "");
|
const dayClass = "duty-timeline-day" + (isToday ? " duty-timeline-day--today" : "");
|
||||||
const dateLabel = isToday ? dateKeyToDDMM(date) : dateKeyToDDMM(date);
|
const dateLabel = isToday ? dateKeyToDDMM(date) : dateKeyToDDMM(date);
|
||||||
const dateCellHtml = isToday
|
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>";
|
: "<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); });
|
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 = "";
|
let dayHtml = "";
|
||||||
|
|||||||
Reference in New Issue
Block a user