Skip to content

Commit 35cf2e4

Browse files
committed
setup for scheduled builds
1 parent bf29e7c commit 35cf2e4

File tree

4 files changed

+74
-3
lines changed

4 files changed

+74
-3
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
1-
name: Discourse stable
1+
name: Discourse ESR
22

33
on:
44
push:
55
branches:
66
- main
77
pull_request:
8+
workflow_dispatch:
89

910
jobs:
1011
ci:
1112
uses: discourse/.github/.github/workflows/discourse-plugin.yml@v1
1213
with:
13-
core_ref: stable
14+
core_ref: esr

.github/workflows/latest.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ on:
55
branches:
66
- main
77
pull_request:
8+
workflow_dispatch:
89

910
jobs:
1011
ci:
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
name: Discourse Branch Update Check
2+
3+
on:
4+
#schedule:
5+
# Runs once a week
6+
#- cron: '34 6 * * 5'
7+
workflow_dispatch:
8+
9+
jobs:
10+
check-updates:
11+
runs-on: ubuntu-latest
12+
strategy:
13+
matrix:
14+
include:
15+
- branch: latest
16+
workflow: latest.yml
17+
- branch: esr
18+
workflow: esr.yml
19+
steps:
20+
- id: retrieve-lastrev
21+
env:
22+
branch: ${{ matrix.branch }}
23+
run: |
24+
git clone --bare --filter=blob:none --depth=1 --single-branch --branch=${branch} https://github.com/discourse/discourse disc
25+
git -C disc rev-parse @ > last-revision
26+
cp last-revision current-revision
27+
- id: cache
28+
uses: actions/cache@v4
29+
with:
30+
path: last-revision
31+
key: uscheck-${{ matrix.branch }}-${{ hashFiles('last-revision') }}
32+
restore-keys: |
33+
uscheck-${{ matrix.branch }}-
34+
- id: trigger-wf
35+
env:
36+
branch: ${{ matrix.branch }}
37+
workflow: ${{ matrix.workflow }}
38+
cache_hit: ${{ steps.cache.outputs.cache-hit }}
39+
GH_TOKEN: ${{ github.token }}
40+
run: |
41+
NEW_REV=$(cat current-revision)
42+
# cache_hit is empty on initial; false when an older cache was restored
43+
[ -n "${cache_hit}" ] && OLD_REV=$(cat last-revision || true)
44+
ls -l current-revision last-revision
45+
echo "NEW_REV=$NEW_REV"
46+
echo "OLD_REV=$OLD_REV"
47+
echo "cache_hit=$cache_hit"
48+
if [ "$NEW_REV" != "$OLD_REV" ]; then
49+
echo "Changes detected"
50+
echo "🆕 Discourse branch ${branch} revision changed" >> $GITHUB_STEP_SUMMARY
51+
echo >> $GITHUB_STEP_SUMMARY
52+
echo "Latest commit: https://github.com/discourse/discourse/commit/${NEW_REV}" >> $GITHUB_STEP_SUMMARY
53+
echo >> $GITHUB_STEP_SUMMARY
54+
if [ -n "${cache_hit}" ]; then
55+
echo "Changes: https://github.com/discourse/discourse/compare/${OLD_REV}...${NEW_REV}" >> $GITHUB_STEP_SUMMARY
56+
echo >> $GITHUB_STEP_SUMMARY
57+
fi
58+
echo "Triggering workflow: ${workflow}" >> $GITHUB_STEP_SUMMARY
59+
60+
echo "$NEW_REV" > last-revision
61+
gh api \
62+
--method POST \
63+
-H "Accept: application/vnd.github+json" \
64+
-H "X-GitHub-Api-Version: 2022-11-28" \
65+
/repos/${GITHUB_REPOSITORY}/actions/workflows/${workflow}/dispatches \
66+
-f "ref=${GITHUB_REF_NAME}"
67+
else
68+
echo "🆗 No changes in Discourse branch: ${branch}" >> $GITHUB_STEP_SUMMARY
69+
fi

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Note: This plugin is still in development and not ready to be used.
88

99
[![Discourse latest](https://github.com/magicball-network/discourse-kofi/actions/workflows/latest.yml/badge.svg)](https://github.com/magicball-network/discourse-kofi/actions/workflows/latest.yml)
1010

11-
[![Discourse stable](https://github.com/magicball-network/discourse-kofi/actions/workflows/stable.yml/badge.svg)](https://github.com/magicball-network/discourse-kofi/actions/workflows/stable.yml)
11+
[![Discourse ESR](https://github.com/magicball-network/discourse-kofi/actions/workflows/esr.yml/badge.svg)](https://github.com/magicball-network/discourse-kofi/actions/workflows/esr.yml)
1212

1313
The above status is based on the plugin's executed tests against the specified Discourse branch.
1414
It is no definite guarantee that there no issues.

0 commit comments

Comments
 (0)