Skip to content

Commit 67edb11

Browse files
test
1 parent f974db3 commit 67edb11

File tree

1 file changed

+55
-57
lines changed

1 file changed

+55
-57
lines changed

.github/workflows/push.yml

Lines changed: 55 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,68 +1,66 @@
11

2-
- name: Checkout repository
3-
uses: actions/checkout@v4
4-
with:
5-
fetch-depth: 0
2+
name: Push summary (single table)
63

7-
- name: Résumé du push (table unique + message complet + liens)
8-
shell: bash
9-
run: |
10-
set -euo pipefail
4+
on:
5+
push:
6+
branches:
7+
- main
118

12-
REPO="${{ github.repository }}"
13-
REPO_URL="https://github.com/${REPO}"
14-
REF="${{ github.ref }}"
15-
ACTOR="${{ github.actor }}"
16-
BEFORE="${{ github.event.before }}"
17-
AFTER="${{ github.sha }}"
18-
RUN_TS_UTC="$(date -u +"%Y-%m-%dT%H:%M:%SZ")"
9+
jobs:
10+
summarize:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Checkout repository
14+
uses: actions/checkout@v4
15+
with:
16+
fetch-depth: 0 # nécessaire pour comparer BEFORE..AFTER [5](https://www.w3tutorials.net/blog/how-to-avoid-having-to-do-git-branch-set-upstream-and-instead-default-to-automatically-setup-remote-tracking/)[4](https://cran.r-project.org/web/packages/rstudioapi/vignettes/introduction.html)
1917

20-
echo "## Résumé (table unique)" >> "$GITHUB_STEP_SUMMARY"
21-
echo "" >> "$GITHUB_STEP_SUMMARY"
18+
- name: Résumé du push (table unique)
19+
shell: bash
20+
run: |
21+
set -euo pipefail
2222
23-
# Tableau unique (tout fusionné)
24-
# Remarque: on évite les colonnes typées numériques (---:) pour pouvoir écrire du texte (ex: lien repo) dans "Valeur".
25-
echo "| Section | Dépôt | Commit | Contributeur | Date commit | Message (complet) | Indicateur | Valeur | Fichier | + | - |" >> "$GITHUB_STEP_SUMMARY"
26-
echo "|---|---|---|---|---|---|---|---|---|---:|---:|" >> "$GITHUB_STEP_SUMMARY"
23+
BEFORE="${{ github.event.before }}"
24+
AFTER="${{ github.sha }}"
2725
28-
# LIGNE META: lien vers le dépôt + infos de branche
29-
echo "| META | [${REPO}](${RE| | | Branche | \`${REF}\` | | | |" >> "$GITHUB_STEP_SUMMARY"
30-
echo "| META | ${REPO} | | | | | Actor | \`${ACTOR}\` | | | |" >> "$GITHUB_STEP_SUMMARY"
31-
echo "| META | ${REPO} | | | | | Date run (UTC) | \`${RUN_TS_UTC}\` | | | |" >> "$GITHUB_STEP_SUMMARY"
32-
echo "| META | [${REPO}](${REPO_URL| Range | \`${BEFORE}..${AFTER}\` | | | |" >> "$GITHUB_STEP_SUMMARY"
26+
echo "## Résumé (table unique)" >> "$GITHUB_STEP_SUMMARY"
27+
echo "" >> "$GITHUB_STEP_SUMMARY"
3328
34-
# 1) COMMITS (SHA cliquable + message complet)
35-
# - SHA court + lien vers le commit
36-
# - message: remplace les retours ligne par <br> pour garder le message complet (titre + corps)
37-
# - échappe le '|' qui casserait le tableau
38-
jq -r --arg repo_url "$REPO_URL" --arg repo "$REPO" '
39-
.commits[]
40-
| .short = (.id[0:7])
41-
| .msg = (.message | gsub("\r\n|\n|\r"; "<br>") | gsub("\\|"; "\\\\|"))
42-
| "| COMMITS | " + $repo + ""
43-
+ " | " + .short + ""
44-
+ " | " + (.author.name // "unknown")
45-
+ " | " + (.timestamp // "unknown")
46-
+ " | " + .msg
47-
+ " | | | | | |"
48-
' "$GITHUB_EVENT_PATH" >> "$GITHUB_STEP_SUMMARY"
29+
# Tableau unique : même structure pour commits + stats + fichiers
30+
echo "| Section | Commit | Contributeur | Date commit | Message | Indicateur | Valeur | Fichier | + | - |" >> "$GITHUB_STEP_SUMMARY"
31+
echo "|---|---|---|---|---|---|---:|---|---:|---:|" >> "$GITHUB_STEP_SUMMARY"
4932
50-
# 2) STATS globales (diff BEFORE -> AFTER)
51-
# GitHub Actions ne fournit plus added/removed/modified dans le payload push → calcul via git diff --numstat. [3](https://docs.posit.co/ide/user/ide/guide/productivity/add-ins.html)[4](https://cran.r-project.org/web/packages/rstudioapi/vignettes/introduction.html)
52-
if [[ "$BEFORE" =~ ^0+$ ]]; then
53-
echo "| STATS | [${REO} | | | | | Premier push | BEFORE=000… (diff non calculable) | | | |" >> "$GITHUB_STEP_SUMMARY"
54-
else
55-
NUMSTAT="$(git diff --numstat "$BEFORE" "$AFTER")"
33+
# ----------------------------
34+
# 1) Lignes COMMITS
35+
# On lit commits[] depuis le payload d’événement (GITHUB_EVENT_PATH). [6](https://rdrr.io/cran/rstudioapi/src/R/commands.R)[7](https://rdrr.io/cran/rstudioapi/src/R/document-api.R)
36+
# On échappe les retours lignes et le caractère '|' pour préserver le tableau.
37+
jq -r '
38+
.commits[]
39+
| .short = (.id[0:7])
40+
| .msg = (.message | gsub("\r\n|\n|\r"; " ") | gsub("\\|"; "\\\\|"))
41+
| "| COMMITS | [" + .short + "](" + (.author.name // "unknown") + " | " + (.timestamp // "unknown") + " | " + .msg + " | | | | | |"
42+
' "$GITHUB_EVENT_PATH" >> "$GITHUB_STEP_SUMMARY"
5643
57-
FILES_CHANGED="$(echo "$NUMSTAT" | wc -l | tr -d ' ')"
58-
ADDED="$(echo "$NUMSTAT" | awk '{a+=$1} END {print a+0}')"
59-
REMOVED="$(echo "$NUMSTAT" | awk '{d+=$2} END {print d+0}')"
60-
MODIFIED_EST=$(( ADDED < REMOVED ? ADDED : REMOVED ))
44+
# ----------------------------
45+
# 2) STATS globales diff BEFORE -> AFTER
46+
# Les champs added/removed/modified ont été retirés du payload push pour Actions,
47+
# donc on calcule via git diff --numstat. [3](https://docs.posit.co/ide/user/ide/guide/productivity/add-ins.html)[4](https://cran.r-project.org/web/packages/rstudioapi/vignettes/introduction.html)
48+
if [[ "$BEFORE" =~ ^0+$ ]]; then
49+
echo "| STATS | | | | | Premier push (BEFORE=000…) | Diff non calculable | | | |" >> "$GITHUB_STEP_SUMMARY"
50+
else
51+
NUMSTAT="$(git diff --numstat "$BEFORE" "$AFTER")" # git diff compare deux commits [4](https://cran.r-project.org/web/packages/rstudioapi/vignettes/introduction.html)
6152
62-
echo "| STATS | [${EPO} | | | | | Fichiers changés | ${FILES_CHANGED} | | | |" >> "$GITHUB_STEP_SUMMARY"
63-
echo "| STATS | ${REPO} | | | | | Lignes ajoutées (+) | ${ADDED} | | | |" >> "$GITHUB_STEP_SUMMARY"
64-
echo "| STATS | ${REPO} | | | | | Lignes supprimées (-) | ${REMOVED} | | | |" >> "$GITHUB_STEP_SUMMARY"
65-
echo "| STATS | ${REPO} | | | | | Estimation lignes modifiées (~) | ${ echo "| STATS | ${REPO} | | | | | Estimation lignes modifiées (~) | ${MODIFIED_EST} | | | |" >> "$GITHUB_STEP_SUMMARY"
53+
FILES_CHANGED="$(echo "$NUMSTAT" | wc -l | tr -d ' ')"
54+
ADDED="$(echo "$NUMSTAT" | awk '{a+=$1} END {print a+0}')"
55+
REMOVED="$(echo "$NUMSTAT" | awk '{d+=$2} END {print d+0}')"
56+
MODIFIED_EST=$(( ADDED < REMOVED ? ADDED : REMOVED )) # estimation ~modifiées (approx) [4](https://cran.r-project.org/web/packages/rstudioapi/vignettes/introduction.html)
6657
67-
# 3) Détail par fichier (+/-)
68-
echo "$NUMSTAT" | awk -F '\t' '{printf "| FICHIERS | '"$REPO"' | | | | | | | `%s` | %s | %s |\n", $3, $1, $2}' >> "$GITHUB_STEP_SUMMARY"
58+
echo "| STATS | | | | | Fichiers changés | $FILES_CHANGED | | | |" >> "$GITHUB_STEP_SUMMARY"
59+
echo "| STATS | | | | | Lignes ajoutées (+) | $ADDED | | | |" >> "$GITHUB_STEP_SUMMARY"
60+
echo "| STATS | | | | | Lignes supprimées (-) | $REMOVED | | | |" >> "$GITHUB_STEP_SUMMARY"
61+
echo "| STATS | | | | | Estimation lignes modifiées (~) | $MODIFIED_EST | | | |" >> "$GITHUB_STEP_SUMMARY"
62+
63+
# ----------------------------
64+
# 3) Détail par fichier (+/-)
65+
# NUMSTAT est "added<TAB>removed<TAB>file" → on le transforme en lignes de tableau.
66+
echo echo "$NUMSTAT" | awk -F '\t' '{printf "| FICHIERS | | | | | | | `%s` | %s | %s |\n", $3, $1, $2}' >> "$GITHUB_STEP_SUMMARY"

0 commit comments

Comments
 (0)