feat: pack auto-rebuilds on any upstream change (CMS/catalogus/nitro/render/emulator) via 15min cron poll
This commit is contained in:
1 parent
87d72a1aef
commit
8b5999970b
1 file changed
+58
-9
@@ -6,6 +6,9 @@ on:
|
|||||||
repository_dispatch:
|
repository_dispatch:
|
||||||
types:
|
types:
|
||||||
- build-pack
|
- build-pack
|
||||||
|
schedule:
|
||||||
|
# Poll all source repos every 15 minutes; rebuild only if a component changed.
|
||||||
|
- cron: "*/15 * * * *"
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
inputs:
|
inputs:
|
||||||
force:
|
force:
|
||||||
@@ -21,8 +24,43 @@ jobs:
|
|||||||
GITEA_REPO: ${{ gitea.repository }}
|
GITEA_REPO: ${{ gitea.repository }}
|
||||||
TOKEN: ${{ secrets.GITEA_TOKEN }}
|
TOKEN: ${{ secrets.GITEA_TOKEN }}
|
||||||
PACK_VERSION: pack-$(date +%Y%m%d-%H%M)
|
PACK_VERSION: pack-$(date +%Y%m%d-%H%M)
|
||||||
|
FORCE: ${{ github.event.inputs.force }}
|
||||||
steps:
|
steps:
|
||||||
|
- name: Check for upstream changes
|
||||||
|
id: check
|
||||||
|
run: |
|
||||||
|
set -e
|
||||||
|
exec 2>&1
|
||||||
|
# Map of repo -> ref to poll for the latest commit hash.
|
||||||
|
CMS_REF="$(git ls-remote https://gitlab.epicnabbo.nl/remco/EpicNext-Cms.git main 2>/dev/null | awk '{print $1}')"
|
||||||
|
CAT_REF="$(git ls-remote https://gitlab.epicnabbo.nl/remco/Epicnabbo-Catalogus-Updated-Daily.git Beta-3 2>/dev/null | awk '{print $1}')"
|
||||||
|
NITRO_REF="$(git ls-remote https://github.com/duckietm/Nitro-V3.git main 2>/dev/null | awk '{print $1}')"
|
||||||
|
RENDER_REF="$(git ls-remote https://github.com/duckietm/Nitro_Render_V3.git main 2>/dev/null | awk '{print $1}')"
|
||||||
|
EMU_REF="$(git ls-remote https://github.com/duckietm/Polaris-Emulator.git main 2>/dev/null | awk '{print $1}')"
|
||||||
|
COMBINED="${CMS_REF}:${CAT_REF}:${NITRO_REF}:${RENDER_REF}:${EMU_REF}"
|
||||||
|
echo "Current refs: $COMBINED"
|
||||||
|
STATE="/var/tmp/pack-refs.state"
|
||||||
|
PREV="$(cat "$STATE" 2>/dev/null || echo "")"
|
||||||
|
if [ "${FORCE:-false}" = "true" ]; then
|
||||||
|
echo "Force rebuild requested"
|
||||||
|
echo "changed=true" >> "$GITHUB_OUTPUT"
|
||||||
|
elif [ "$COMBINED" != "$PREV" ]; then
|
||||||
|
echo "Upstream change detected (was: $PREV)"
|
||||||
|
echo "changed=true" >> "$GITHUB_OUTPUT"
|
||||||
|
else
|
||||||
|
echo "No upstream changes since last pack"
|
||||||
|
echo "changed=false" >> "$GITHUB_OUTPUT"
|
||||||
|
fi
|
||||||
|
echo "$COMBINED" > "$STATE"
|
||||||
|
|
||||||
|
- name: Skip if unchanged
|
||||||
|
if: steps.check.outputs.changed != 'true'
|
||||||
|
run: |
|
||||||
|
echo "Nothing to rebuild. Exiting."
|
||||||
|
exit 0
|
||||||
|
|
||||||
- name: Setup
|
- name: Setup
|
||||||
|
if: steps.check.outputs.changed == 'true'
|
||||||
run: |
|
run: |
|
||||||
set -e
|
set -e
|
||||||
exec 2>&1
|
exec 2>&1
|
||||||
@@ -32,6 +70,7 @@ jobs:
|
|||||||
echo "WORK=$WORK" >> "$GITHUB_ENV"
|
echo "WORK=$WORK" >> "$GITHUB_ENV"
|
||||||
|
|
||||||
- name: Pull CMS (this repo)
|
- name: Pull CMS (this repo)
|
||||||
|
if: steps.check.outputs.changed == 'true'
|
||||||
run: |
|
run: |
|
||||||
set -e
|
set -e
|
||||||
git clone --depth 1 "${{ gitea.server_url }}/${{ gitea.repository }}.git" "$WORK/src/cms" 2>/dev/null \
|
git clone --depth 1 "${{ gitea.server_url }}/${{ gitea.repository }}.git" "$WORK/src/cms" 2>/dev/null \
|
||||||
@@ -39,6 +78,7 @@ jobs:
|
|||||||
echo "cms: $(git -C "$WORK/src/cms" rev-parse --short HEAD 2>/dev/null)" | tee -a "$WORK/components.txt"
|
echo "cms: $(git -C "$WORK/src/cms" rev-parse --short HEAD 2>/dev/null)" | tee -a "$WORK/components.txt"
|
||||||
|
|
||||||
- name: Pull Catalogus
|
- name: Pull Catalogus
|
||||||
|
if: steps.check.outputs.changed == 'true'
|
||||||
run: |
|
run: |
|
||||||
set -e
|
set -e
|
||||||
git clone --depth 1 https://gitlab.epicnabbo.nl/remco/Epicnabbo-Catalogus-Updated-Daily.git "$WORK/src/catalogus" 2>/dev/null \
|
git clone --depth 1 https://gitlab.epicnabbo.nl/remco/Epicnabbo-Catalogus-Updated-Daily.git "$WORK/src/catalogus" 2>/dev/null \
|
||||||
@@ -46,6 +86,7 @@ jobs:
|
|||||||
echo "catalogus: $(git -C "$WORK/src/catalogus" rev-parse --short HEAD 2>/dev/null)" | tee -a "$WORK/components.txt"
|
echo "catalogus: $(git -C "$WORK/src/catalogus" rev-parse --short HEAD 2>/dev/null)" | tee -a "$WORK/components.txt"
|
||||||
|
|
||||||
- name: Pull Nitro-V3
|
- name: Pull Nitro-V3
|
||||||
|
if: steps.check.outputs.changed == 'true'
|
||||||
run: |
|
run: |
|
||||||
set -e
|
set -e
|
||||||
git clone --depth 1 https://github.com/duckietm/Nitro-V3.git "$WORK/src/nitro" 2>/dev/null \
|
git clone --depth 1 https://github.com/duckietm/Nitro-V3.git "$WORK/src/nitro" 2>/dev/null \
|
||||||
@@ -53,6 +94,7 @@ jobs:
|
|||||||
echo "nitro: $(git -C "$WORK/src/nitro" rev-parse --short HEAD 2>/dev/null)" | tee -a "$WORK/components.txt"
|
echo "nitro: $(git -C "$WORK/src/nitro" rev-parse --short HEAD 2>/dev/null)" | tee -a "$WORK/components.txt"
|
||||||
|
|
||||||
- name: Pull Nitro-Render-V3
|
- name: Pull Nitro-Render-V3
|
||||||
|
if: steps.check.outputs.changed == 'true'
|
||||||
run: |
|
run: |
|
||||||
set -e
|
set -e
|
||||||
git clone --depth 1 https://github.com/duckietm/Nitro_Render_V3.git "$WORK/src/render" 2>/dev/null \
|
git clone --depth 1 https://github.com/duckietm/Nitro_Render_V3.git "$WORK/src/render" 2>/dev/null \
|
||||||
@@ -60,6 +102,7 @@ jobs:
|
|||||||
echo "render: $(git -C "$WORK/src/render" rev-parse --short HEAD 2>/dev/null)" | tee -a "$WORK/components.txt"
|
echo "render: $(git -C "$WORK/src/render" rev-parse --short HEAD 2>/dev/null)" | tee -a "$WORK/components.txt"
|
||||||
|
|
||||||
- name: Pull Polaris Emulator
|
- name: Pull Polaris Emulator
|
||||||
|
if: steps.check.outputs.changed == 'true'
|
||||||
run: |
|
run: |
|
||||||
set -e
|
set -e
|
||||||
git clone --depth 1 https://github.com/duckietm/Polaris-Emulator.git "$WORK/src/emulator" 2>/dev/null \
|
git clone --depth 1 https://github.com/duckietm/Polaris-Emulator.git "$WORK/src/emulator" 2>/dev/null \
|
||||||
@@ -67,6 +110,7 @@ jobs:
|
|||||||
echo "emulator: $(git -C "$WORK/src/emulator" rev-parse --short HEAD 2>/dev/null)" | tee -a "$WORK/components.txt"
|
echo "emulator: $(git -C "$WORK/src/emulator" rev-parse --short HEAD 2>/dev/null)" | tee -a "$WORK/components.txt"
|
||||||
|
|
||||||
- name: Build Nitro-V3 client
|
- name: Build Nitro-V3 client
|
||||||
|
if: steps.check.outputs.changed == 'true'
|
||||||
run: |
|
run: |
|
||||||
set -e
|
set -e
|
||||||
cd "$WORK/src/nitro"
|
cd "$WORK/src/nitro"
|
||||||
@@ -77,6 +121,7 @@ jobs:
|
|||||||
echo "nitro built" | tee -a "$WORK/build.txt"
|
echo "nitro built" | tee -a "$WORK/build.txt"
|
||||||
|
|
||||||
- name: Build Nitro-Render-V3
|
- name: Build Nitro-Render-V3
|
||||||
|
if: steps.check.outputs.changed == 'true'
|
||||||
run: |
|
run: |
|
||||||
set -e
|
set -e
|
||||||
cd "$WORK/src/render"
|
cd "$WORK/src/render"
|
||||||
@@ -87,6 +132,7 @@ jobs:
|
|||||||
echo "render built" | tee -a "$WORK/build.txt"
|
echo "render built" | tee -a "$WORK/build.txt"
|
||||||
|
|
||||||
- name: Build Polaris Emulator
|
- name: Build Polaris Emulator
|
||||||
|
if: steps.check.outputs.changed == 'true'
|
||||||
run: |
|
run: |
|
||||||
set -e
|
set -e
|
||||||
cd "$WORK/src/emulator"
|
cd "$WORK/src/emulator"
|
||||||
@@ -97,6 +143,7 @@ jobs:
|
|||||||
echo "emulator built" | tee -a "$WORK/build.txt"
|
echo "emulator built" | tee -a "$WORK/build.txt"
|
||||||
|
|
||||||
- name: Assemble Pack
|
- name: Assemble Pack
|
||||||
|
if: steps.check.outputs.changed == 'true'
|
||||||
run: |
|
run: |
|
||||||
set -e
|
set -e
|
||||||
cd "$WORK/out"
|
cd "$WORK/out"
|
||||||
@@ -114,15 +161,12 @@ jobs:
|
|||||||
echo "Pack created: $(du -h "$PACK_FILE" | cut -f1)"
|
echo "Pack created: $(du -h "$PACK_FILE" | cut -f1)"
|
||||||
|
|
||||||
- name: Build Changelog
|
- name: Build Changelog
|
||||||
|
if: steps.check.outputs.changed == 'true'
|
||||||
run: |
|
run: |
|
||||||
set -e
|
set -e
|
||||||
BARE="/docker/gitea/gitea/git/repositories/remco/epicnext-cms.git"
|
BARE="/docker/gitea/gitea/git/repositories/remco/epicnext-cms.git"
|
||||||
PREV="$(git -C "$BARE" tag --list 'pack-*' --sort=-creatordate | head -1 || echo '')"
|
PREV="$(git -C "$BARE" tag --list 'pack-*' --sort=-creatordate | head -1 || echo '')"
|
||||||
if [ -n "$PREV" ]; then
|
PREV_NOTE="${PREV:-initial}"
|
||||||
CMS_LOG="$(git -C "$BARE" log --oneline --no-decorate "${PREV}..HEAD" 2>/dev/null || echo "")"
|
|
||||||
else
|
|
||||||
CMS_LOG="$(git -C "$BARE" log --oneline --no-decorate -5 2>/dev/null || echo "")"
|
|
||||||
fi
|
|
||||||
{
|
{
|
||||||
echo "## Site Pack ${PACK_VERSION}"
|
echo "## Site Pack ${PACK_VERSION}"
|
||||||
echo ""
|
echo ""
|
||||||
@@ -131,14 +175,19 @@ jobs:
|
|||||||
cat "$WORK/components.txt"
|
cat "$WORK/components.txt"
|
||||||
echo '```'
|
echo '```'
|
||||||
echo ""
|
echo ""
|
||||||
echo "### CMS changes since ${PREV:-none}"
|
echo "### Changes since pack ${PREV_NOTE}"
|
||||||
echo '```'
|
for pair in "cms:$WORK/src/cms" "catalogus:$WORK/src/catalogus" "nitro:$WORK/src/nitro" "render:$WORK/src/render" "emulator:$WORK/src/emulator"; do
|
||||||
echo "${CMS_LOG:-none}"
|
label="${pair%%:*}"; repo="${pair##*:}"
|
||||||
echo '```'
|
echo "**${label}**"
|
||||||
|
echo '```'
|
||||||
|
git -C "$repo" log --oneline --no-decorate -10 2>/dev/null || echo "n/a"
|
||||||
|
echo '```'
|
||||||
|
done
|
||||||
} > /tmp/pack-body.md
|
} > /tmp/pack-body.md
|
||||||
cat /tmp/pack-body.md
|
cat /tmp/pack-body.md
|
||||||
|
|
||||||
- name: Create Release + Upload Pack
|
- name: Create Release + Upload Pack
|
||||||
|
if: steps.check.outputs.changed == 'true'
|
||||||
run: |
|
run: |
|
||||||
set -e
|
set -e
|
||||||
BODY="$(jq -Rs '.' < /tmp/pack-body.md)"
|
BODY="$(jq -Rs '.' < /tmp/pack-body.md)"
|
||||||
|
|||||||
Reference in new issue
Block a user