Skip to content
This repository was archived by the owner on Apr 30, 2026. It is now read-only.

Commit e5b3e89

Browse files
committed
fix: actually list commits
1 parent 0379740 commit e5b3e89

1 file changed

Lines changed: 36 additions & 34 deletions

File tree

.github/workflows/push-build-discord.yml

Lines changed: 36 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -64,57 +64,59 @@ jobs:
6464
exit 1
6565
fi
6666
67-
# Build commit lines and compare URL
68-
commit_lines=""
69-
if [[ -n "${BEFORE_SHA}" && "${BEFORE_SHA}" != "0000000000000000000000000000000000000000" ]]; then
70-
before_short="${BEFORE_SHA:0:8}"
71-
hash_range="${before_short}...${SHORT_SHA}"
72-
compare_url="https://github.com/${GITHUB_REPOSITORY}/compare/${BEFORE_SHA}...${GITHUB_SHA}"
73-
while IFS='|' read -r hash full_hash message author; do
74-
[[ -z "$hash" ]] && continue
75-
line_url="https://github.com/${GITHUB_REPOSITORY}/commit/${full_hash}"
76-
commit_lines="${commit_lines}\n- [\`${hash}\`](${line_url}) ${message} - by ${author}"
77-
done < <(git log --pretty=format:"%h|%H|%s|%an" "${BEFORE_SHA}..HEAD" 2>/dev/null | head -10)
78-
else
79-
hash_range="${SHORT_SHA}"
80-
compare_url="https://github.com/${GITHUB_REPOSITORY}/commit/${GITHUB_SHA}"
81-
while IFS='|' read -r hash full_hash message author; do
82-
[[ -z "$hash" ]] && continue
83-
line_url="https://github.com/${GITHUB_REPOSITORY}/commit/${full_hash}"
84-
commit_lines="${commit_lines}\n- [\`${hash}\`](${line_url}) ${message} - by ${author}"
85-
done < <(git log --pretty=format:"%h|%H|%s|%an" -5 2>/dev/null)
86-
fi
87-
88-
export COMMIT_LINES="${commit_lines}"
89-
export HASH_RANGE="${hash_range}"
90-
export COMPARE_URL="${compare_url}"
91-
export TIMESTAMP="$(date -u +"%Y-%m-%dT%H:%M:%SZ")"
92-
9367
payload=$(python3 -c "
94-
import json, os
68+
import json, os, subprocess
69+
9570
repo = os.environ['GITHUB_REPOSITORY']
9671
repo_url = f'https://github.com/{repo}'
97-
compare_url = os.environ['COMPARE_URL']
98-
hash_range = os.environ['HASH_RANGE']
9972
branch = os.environ['GITHUB_REF_NAME']
10073
artifact = os.environ['ARTIFACT_NAME']
101-
commits = os.environ.get('COMMIT_LINES', '').replace('\\\\n', '\n')
102-
timestamp = os.environ['TIMESTAMP']
74+
current_sha = os.environ['GITHUB_SHA']
75+
short_sha = os.environ['SHORT_SHA']
76+
before_sha = os.environ.get('BEFORE_SHA', '').strip()
77+
timestamp = subprocess.check_output(['date', '-u', '+%Y-%m-%dT%H:%M:%SZ']).decode().strip()
78+
79+
null_sha = '0000000000000000000000000000000000000000'
80+
if before_sha and before_sha != null_sha:
81+
before_short = before_sha[:8]
82+
hash_range = f'{before_short}...{short_sha}'
83+
compare_url = f'https://github.com/{repo}/compare/{before_sha}...{current_sha}'
84+
git_range = f'{before_sha}..HEAD'
85+
extra_args = [git_range]
86+
else:
87+
hash_range = short_sha
88+
compare_url = f'https://github.com/{repo}/commit/{current_sha}'
89+
extra_args = ['-5']
90+
91+
log = subprocess.check_output(
92+
['git', 'log', '--pretty=format:%h|%H|%s|%an'] + extra_args
93+
).decode().strip()
94+
95+
commit_lines = ''
96+
for line in log.splitlines():
97+
if not line:
98+
continue
99+
parts = line.split('|', 3)
100+
if len(parts) < 4:
101+
continue
102+
h, full_h, msg, author = parts
103+
url = f'https://github.com/{repo}/commit/{full_h}'
104+
commit_lines += f'\n- [\`{h}\`]({url}) {msg} - by {author}'
103105
104106
description = (
105107
f'🔗 **GitHub Repository:** {repo_url}\n\n'
106108
f'[{hash_range}]({compare_url})'
107-
f'{commits}\n\n'
109+
f'{commit_lines}\n\n'
108110
f'**Build attached below**'
109111
)
110112
111113
payload = {
112-
'content': '<@&1498285672543424559>',
114+
'content': 'Test',
113115
'embeds': [{
114116
'title': f'Building mod from branch {branch}',
115117
'color': 2303786,
116118
'description': description,
117-
'footer': {'text': 'Create: Propulsion Sable - Nightly'},
119+
'footer': {'text': 'RocketNautics Auto-Release'},
118120
'timestamp': timestamp
119121
}]
120122
}

0 commit comments

Comments
 (0)