55
Jenkinsfile
vendored
Normal file
@ -0,0 +1,55 @@
|
||||
@Library("cadoles") _
|
||||
|
||||
pipeline {
|
||||
agent {
|
||||
dockerfile {
|
||||
label 'docker'
|
||||
filename 'Dockerfile'
|
||||
dir 'misc/ci'
|
||||
}
|
||||
}
|
||||
|
||||
triggers {
|
||||
cron('0 9 * * 1')
|
||||
}
|
||||
|
||||
stages {
|
||||
stage("Send newsletter") {
|
||||
when {
|
||||
anyOf {
|
||||
triggeredBy cause: "UserIdCause", detail: "wpetit"
|
||||
triggeredBy 'TimerTrigger'
|
||||
}
|
||||
}
|
||||
steps {
|
||||
script {
|
||||
String newsletter = sh(script: "bash ./generate-newsletter.sh", returnStdout: true)
|
||||
if (newsletter) {
|
||||
rocketSend(
|
||||
channel: '#TechWatch',
|
||||
message: newsletter,
|
||||
rawMessage: true
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
stage("Send test newsletter to wpetit") {
|
||||
when {
|
||||
branch 'master'
|
||||
}
|
||||
steps {
|
||||
script {
|
||||
String newsletter = sh(script: "bash ./generate-newsletter.sh", returnStdout: true)
|
||||
if (newsletter) {
|
||||
rocketSend(
|
||||
channel: '@wpetit',
|
||||
message: newsletter,
|
||||
rawMessage: true
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
126
generate-newsletter.sh
Executable file
@ -0,0 +1,126 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -eo pipefail
|
||||
|
||||
NEWSLETTER=""
|
||||
|
||||
function write {
|
||||
local content=$@
|
||||
NEWSLETTER="${NEWSLETTER}${content}"
|
||||
}
|
||||
|
||||
function writeln {
|
||||
write "$@\n"
|
||||
}
|
||||
|
||||
function include_illustration_of_the_week {
|
||||
local illustration_of_the_week=$(date +"illustrations/%Y/small/%U.jpg")
|
||||
|
||||
if [ ! -f "${illustration_of_the_week}" ]; then
|
||||
return
|
||||
fi
|
||||
|
||||
writeln
|
||||
writeln "![L'illustration de la semaine](https://forge.cadoles.com/wpetit/cazette/raw/branch/master/$illustration_of_the_week)"
|
||||
}
|
||||
|
||||
function include_subreddit_top_of_the_week {
|
||||
local title=$1
|
||||
local subreddit=$2
|
||||
local total=$3
|
||||
local top_of_the_week=$(curl -sk --retry 5 "https://www.reddit.com/r/$subreddit/top/.rss?sort=top&t=week" | npx xml2json | jq --arg TOTAL "$total" '.feed.entry[0:($TOTAL|tonumber)]')
|
||||
|
||||
if [ -z "$top_of_the_week" ]; then
|
||||
return
|
||||
fi
|
||||
|
||||
writeln
|
||||
writeln "#### ${title}"
|
||||
|
||||
for index in $(seq 0 $(( $total - 1 ))); do
|
||||
local entry=$(echo $top_of_the_week | jq --arg INDEX $index '.[$INDEX | tonumber]')
|
||||
local entry_title=$(echo $entry | jq -r '.title')
|
||||
local entry_url=$(echo $entry | jq -r '.link.href')
|
||||
local entry_author=$(echo $entry | jq -r '.author? | .name?')
|
||||
|
||||
write "- [${entry_title}]($entry_url)"
|
||||
if [ ! -z "${entry_author}" ]; then
|
||||
writeln " par _ ${entry_author} _"
|
||||
else
|
||||
writeln
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
function include_linuxfr_latest {
|
||||
local total=5
|
||||
local linuxfr_latest=$(curl -sk --retry 5 https://linuxfr.org/news.atom | npx xml2json | jq --arg TOTAL "$total" '.feed.entry[0:($TOTAL|tonumber)]')
|
||||
|
||||
if [ -z "$linuxfr_latest" ]; then
|
||||
return
|
||||
fi
|
||||
|
||||
writeln
|
||||
writeln "#### LinuxFr.org"
|
||||
|
||||
for index in $(seq 0 $(( $total - 1 ))); do
|
||||
local entry=$(echo $linuxfr_latest | jq --arg INDEX $index '.[$INDEX | tonumber]')
|
||||
local entry_title=$(echo $entry | jq -r '.title')
|
||||
local entry_url=$(echo $entry | jq -r '.link.href')
|
||||
local entry_author=$(echo $entry | jq -r '[.author? | .[] | .name?] | join(", ")')
|
||||
|
||||
write "- [${entry_title}]($entry_url)"
|
||||
if [ ! -z "${entry_author}" ]; then
|
||||
writeln " par _ ${entry_author} _"
|
||||
else
|
||||
writeln
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
function include_hackernews_top5 {
|
||||
local hackernews_top5=$(curl -sk --retry 5 https://hacker-news.firebaseio.com/v0/topstories.json | jq -r '.[0:5] | .[]')
|
||||
|
||||
if [ -z "$hackernews_top5" ]; then
|
||||
return
|
||||
fi
|
||||
|
||||
writeln
|
||||
writeln "#### Hackernews"
|
||||
|
||||
for story_id in ${hackernews_top5}; do
|
||||
local hackernews_story=$(curl -sk --retry 5 https://hacker-news.firebaseio.com/v0/item/$story_id.json?print=pretty)
|
||||
local story_title=$(echo $hackernews_story | jq -r '.title')
|
||||
local story_url=$(echo $hackernews_story | jq -r '.url')
|
||||
local story_author=$(echo $hackernews_story | jq -r '.by')
|
||||
|
||||
write "- [${story_title}](${story_url})"
|
||||
if [ ! -z "${story_author}" ]; then
|
||||
writeln " par _ ${story_author} _"
|
||||
else
|
||||
writeln
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
function main() {
|
||||
include_subreddit_top_of_the_week "Généralités" "programmation" 5
|
||||
include_subreddit_top_of_the_week "Go" "golang" 5
|
||||
include_subreddit_top_of_the_week "Kubernetes" "kubernetes" 5
|
||||
include_subreddit_top_of_the_week "Python" "python" 5
|
||||
include_subreddit_top_of_the_week "PHP" "php" 5
|
||||
include_linuxfr_latest
|
||||
include_hackernews_top5
|
||||
include_illustration_of_the_week
|
||||
|
||||
if [ ! -z "$NEWSLETTER" ]; then
|
||||
echo "### La Cazette N°$(date +%Y-%U)"
|
||||
echo "_Chaque semaine, une sélection de nouvelles et d'articles de la communauté du développement logiciel._"
|
||||
echo -e $NEWSLETTER
|
||||
echo "**Bonne semaine à tous ! :robot:**"
|
||||
echo
|
||||
echo "_Generated by [cazette](https://forge.cadoles.com/wpetit/cazette)_"
|
||||
fi
|
||||
}
|
||||
|
||||
main
|
BIN
illustrations/2025/03.jpg
Normal file
After Width: | Height: | Size: 90 KiB |
BIN
illustrations/2025/04.jpg
Normal file
After Width: | Height: | Size: 78 KiB |
BIN
illustrations/2025/05.jpg
Normal file
After Width: | Height: | Size: 166 KiB |
BIN
illustrations/2025/06.jpg
Normal file
After Width: | Height: | Size: 197 KiB |
BIN
illustrations/2025/07.jpg
Normal file
After Width: | Height: | Size: 164 KiB |
BIN
illustrations/2025/08.jpg
Normal file
After Width: | Height: | Size: 101 KiB |
BIN
illustrations/2025/09.jpg
Normal file
After Width: | Height: | Size: 112 KiB |
BIN
illustrations/2025/10.jpg
Normal file
After Width: | Height: | Size: 63 KiB |
BIN
illustrations/2025/11.jpg
Normal file
After Width: | Height: | Size: 69 KiB |
BIN
illustrations/2025/12.jpg
Normal file
After Width: | Height: | Size: 89 KiB |
BIN
illustrations/2025/13.jpg
Normal file
After Width: | Height: | Size: 73 KiB |
BIN
illustrations/2025/14.jpg
Normal file
After Width: | Height: | Size: 88 KiB |
BIN
illustrations/2025/15.jpg
Normal file
After Width: | Height: | Size: 111 KiB |
BIN
illustrations/2025/16.jpg
Normal file
After Width: | Height: | Size: 174 KiB |
BIN
illustrations/2025/17.jpg
Normal file
After Width: | Height: | Size: 91 KiB |
BIN
illustrations/2025/18.jpg
Normal file
After Width: | Height: | Size: 68 KiB |
BIN
illustrations/2025/19.jpg
Normal file
After Width: | Height: | Size: 121 KiB |
BIN
illustrations/2025/20.jpg
Normal file
After Width: | Height: | Size: 163 KiB |
BIN
illustrations/2025/21.jpg
Normal file
After Width: | Height: | Size: 115 KiB |
BIN
illustrations/2025/22.jpg
Normal file
After Width: | Height: | Size: 160 KiB |
BIN
illustrations/2025/23.jpg
Normal file
After Width: | Height: | Size: 112 KiB |
BIN
illustrations/2025/24.jpg
Normal file
After Width: | Height: | Size: 121 KiB |
BIN
illustrations/2025/25.jpg
Normal file
After Width: | Height: | Size: 115 KiB |
BIN
illustrations/2025/26.jpg
Normal file
After Width: | Height: | Size: 128 KiB |
BIN
illustrations/2025/27.jpg
Normal file
After Width: | Height: | Size: 102 KiB |
BIN
illustrations/2025/28.jpg
Normal file
After Width: | Height: | Size: 111 KiB |
BIN
illustrations/2025/29.jpg
Normal file
After Width: | Height: | Size: 173 KiB |
BIN
illustrations/2025/30.jpg
Normal file
After Width: | Height: | Size: 146 KiB |
BIN
illustrations/2025/31.jpg
Normal file
After Width: | Height: | Size: 136 KiB |
BIN
illustrations/2025/32.jpg
Normal file
After Width: | Height: | Size: 162 KiB |
BIN
illustrations/2025/33.jpg
Normal file
After Width: | Height: | Size: 88 KiB |
BIN
illustrations/2025/34.jpg
Normal file
After Width: | Height: | Size: 118 KiB |
BIN
illustrations/2025/35.jpg
Normal file
After Width: | Height: | Size: 123 KiB |
BIN
illustrations/2025/36.jpg
Normal file
After Width: | Height: | Size: 109 KiB |
BIN
illustrations/2025/37.jpg
Normal file
After Width: | Height: | Size: 76 KiB |
BIN
illustrations/2025/38.jpg
Normal file
After Width: | Height: | Size: 93 KiB |
BIN
illustrations/2025/39.jpg
Normal file
After Width: | Height: | Size: 89 KiB |
BIN
illustrations/2025/40.jpg
Normal file
After Width: | Height: | Size: 134 KiB |
BIN
illustrations/2025/41.jpg
Normal file
After Width: | Height: | Size: 97 KiB |
BIN
illustrations/2025/42.jpg
Normal file
After Width: | Height: | Size: 176 KiB |
BIN
illustrations/2025/43.jpg
Normal file
After Width: | Height: | Size: 166 KiB |
BIN
illustrations/2025/44.jpg
Normal file
After Width: | Height: | Size: 201 KiB |
BIN
illustrations/2025/45.jpg
Normal file
After Width: | Height: | Size: 82 KiB |
BIN
illustrations/2025/46.jpg
Normal file
After Width: | Height: | Size: 120 KiB |
BIN
illustrations/2025/47.jpg
Normal file
After Width: | Height: | Size: 94 KiB |
BIN
illustrations/2025/48.jpg
Normal file
After Width: | Height: | Size: 111 KiB |
BIN
illustrations/2025/49.jpg
Normal file
After Width: | Height: | Size: 67 KiB |
BIN
illustrations/2025/50.jpg
Normal file
After Width: | Height: | Size: 144 KiB |
BIN
illustrations/2025/51.jpg
Normal file
After Width: | Height: | Size: 131 KiB |
BIN
illustrations/2025/52.jpg
Normal file
After Width: | Height: | Size: 98 KiB |
BIN
illustrations/2025/small/03.jpg
Normal file
After Width: | Height: | Size: 54 KiB |
BIN
illustrations/2025/small/04.jpg
Normal file
After Width: | Height: | Size: 47 KiB |
BIN
illustrations/2025/small/05.jpg
Normal file
After Width: | Height: | Size: 103 KiB |
BIN
illustrations/2025/small/06.jpg
Normal file
After Width: | Height: | Size: 107 KiB |
BIN
illustrations/2025/small/07.jpg
Normal file
After Width: | Height: | Size: 99 KiB |
BIN
illustrations/2025/small/08.jpg
Normal file
After Width: | Height: | Size: 61 KiB |
BIN
illustrations/2025/small/09.jpg
Normal file
After Width: | Height: | Size: 67 KiB |
BIN
illustrations/2025/small/10.jpg
Normal file
After Width: | Height: | Size: 37 KiB |
BIN
illustrations/2025/small/11.jpg
Normal file
After Width: | Height: | Size: 43 KiB |
BIN
illustrations/2025/small/12.jpg
Normal file
After Width: | Height: | Size: 54 KiB |
BIN
illustrations/2025/small/13.jpg
Normal file
After Width: | Height: | Size: 40 KiB |
BIN
illustrations/2025/small/14.jpg
Normal file
After Width: | Height: | Size: 52 KiB |
BIN
illustrations/2025/small/15.jpg
Normal file
After Width: | Height: | Size: 67 KiB |
BIN
illustrations/2025/small/16.jpg
Normal file
After Width: | Height: | Size: 106 KiB |
BIN
illustrations/2025/small/17.jpg
Normal file
After Width: | Height: | Size: 56 KiB |
BIN
illustrations/2025/small/18.jpg
Normal file
After Width: | Height: | Size: 41 KiB |
BIN
illustrations/2025/small/19.jpg
Normal file
After Width: | Height: | Size: 74 KiB |
BIN
illustrations/2025/small/20.jpg
Normal file
After Width: | Height: | Size: 101 KiB |
BIN
illustrations/2025/small/21.jpg
Normal file
After Width: | Height: | Size: 71 KiB |
BIN
illustrations/2025/small/22.jpg
Normal file
After Width: | Height: | Size: 98 KiB |
BIN
illustrations/2025/small/23.jpg
Normal file
After Width: | Height: | Size: 68 KiB |
BIN
illustrations/2025/small/24.jpg
Normal file
After Width: | Height: | Size: 77 KiB |
BIN
illustrations/2025/small/25.jpg
Normal file
After Width: | Height: | Size: 70 KiB |
BIN
illustrations/2025/small/26.jpg
Normal file
After Width: | Height: | Size: 80 KiB |
BIN
illustrations/2025/small/27.jpg
Normal file
After Width: | Height: | Size: 62 KiB |
BIN
illustrations/2025/small/28.jpg
Normal file
After Width: | Height: | Size: 66 KiB |
BIN
illustrations/2025/small/29.jpg
Normal file
After Width: | Height: | Size: 104 KiB |
BIN
illustrations/2025/small/30.jpg
Normal file
After Width: | Height: | Size: 89 KiB |
BIN
illustrations/2025/small/31.jpg
Normal file
After Width: | Height: | Size: 81 KiB |
BIN
illustrations/2025/small/32.jpg
Normal file
After Width: | Height: | Size: 99 KiB |
BIN
illustrations/2025/small/33.jpg
Normal file
After Width: | Height: | Size: 53 KiB |
BIN
illustrations/2025/small/34.jpg
Normal file
After Width: | Height: | Size: 67 KiB |
BIN
illustrations/2025/small/35.jpg
Normal file
After Width: | Height: | Size: 78 KiB |
BIN
illustrations/2025/small/36.jpg
Normal file
After Width: | Height: | Size: 66 KiB |
BIN
illustrations/2025/small/37.jpg
Normal file
After Width: | Height: | Size: 46 KiB |
BIN
illustrations/2025/small/38.jpg
Normal file
After Width: | Height: | Size: 54 KiB |
BIN
illustrations/2025/small/39.jpg
Normal file
After Width: | Height: | Size: 53 KiB |
BIN
illustrations/2025/small/40.jpg
Normal file
After Width: | Height: | Size: 84 KiB |
BIN
illustrations/2025/small/41.jpg
Normal file
After Width: | Height: | Size: 57 KiB |
BIN
illustrations/2025/small/42.jpg
Normal file
After Width: | Height: | Size: 106 KiB |
BIN
illustrations/2025/small/43.jpg
Normal file
After Width: | Height: | Size: 98 KiB |
BIN
illustrations/2025/small/44.jpg
Normal file
After Width: | Height: | Size: 119 KiB |
BIN
illustrations/2025/small/45.jpg
Normal file
After Width: | Height: | Size: 51 KiB |
BIN
illustrations/2025/small/46.jpg
Normal file
After Width: | Height: | Size: 73 KiB |
BIN
illustrations/2025/small/47.jpg
Normal file
After Width: | Height: | Size: 59 KiB |
BIN
illustrations/2025/small/48.jpg
Normal file
After Width: | Height: | Size: 59 KiB |
BIN
illustrations/2025/small/49.jpg
Normal file
After Width: | Height: | Size: 40 KiB |