diff --git a/.github/workflows/update-insights.yml b/.github/workflows/update-insights.yml new file mode 100644 index 0000000000..ec7ae4b704 --- /dev/null +++ b/.github/workflows/update-insights.yml @@ -0,0 +1,121 @@ +name: Update Insights Sessions archive/upcoming + +on: + schedule: + - cron: '0 * * * 1' + workflow_dispatch: + +permissions: + contents: write + pull-requests: write + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 + +# - name: Install yq (for yml manipulation) +# run: sudo apt-get update && sudo apt-get install -y yq + + - name: Archive current session + id: archive_session + env: + YOUTUBE_API_KEY: ${{ secrets.INSIGHTS_YOUTUBE_API_KEY }} + YOUTUBE_CHANNEL_ID: ${{ secrets.INSIGHTS_YOUTUBE_CHANNEL_ID }} + run: | + today=$(date +"%B %d, %Y") + + nextsessiondate=$(yq -r '.nextsessiondate' _data/insights-videos.yaml) + nextsessiondate_formatted=$(date --date=$nextsessiondate +"%B %d, %Y") + + if [ "$today" != "$nextsessiondate_formatted" ]; then + echo "Next session date ($nextsessiondate_formatted) does not match today's date ($today). Skipping workflow run." + exit 0 + fi + + current_episode=$(yq -r '.nextsessiontitle | sub(".* #([0-9]+):.*"; "${1}")' _data/insights-videos.yaml) + echo $current_episode + + youtube_response=$(curl -s --fail \ + -H "X-goog-api-key: ${YOUTUBE_API_KEY}" \ + "https://www.googleapis.com/youtube/v3/search?part=snippet&channelId=${YOUTUBE_CHANNEL_ID}&q=%23${current_episode}&type=video") + + video_id=$(echo $youtube_response | jq -r '.items[0].id.videoId') + video_status=$(echo $youtube_response | jq -r '.items[0].snippet.liveBroadcastContent') + video_title=$(echo $youtube_response | jq -r '.items[0].snippet.title') + + # Check if a video ID was found + if [ -z "$video_id" ] || [ "$video_id" == "null" ]; then + echo "Could not find the YouTube video for episode #$current_episode. Assuming it's not there yet. Exiting..." + exit 0 + fi + + if [[ "$video_title" == *"#$current_episode"* ]]; then + echo "The video title contains the required episode number: '#$current_episode'" + else + echo "The video title does NOT contain the required episode number: '#$current_episode'. Exiting..." + exit 1 + fi + + if [ "$video_status" != "none" ]; then + echo "Expecting the video status to be 'none' but instead it is: $video_status. Exiting..." + exit 0 + fi + + video_link="https://www.youtube.com/watch?v=${video_id}" + nextsessiontitle="$(yq '.nextsessiontitle' _data/insights-videos.yaml)" + nextsessionguest="$(yq '.nextsessionguest' _data/insights-videos.yaml)" + + yq -i ' + .pastvideos = [ + { + "title": "'"$nextsessiontitle"'", + "date": "'"$nextsessiondate_formatted"'", + "authors": "'"$nextsessionguest"'", + "link": "'"$video_link"'" + } + ] + .pastvideos + ' _data/insights-videos.yaml + + echo "title=$(yq '.nextsessiontitle' _data/insights-videos.yaml)" >> "$GITHUB_OUTPUT" + - name: Set next session information + if: steps.archive_session.outputs.title != '' + run: | + yq -i 'del(.futurevideos[0])' _data/insights-videos.yaml + + title=$(yq '.futurevideos[0].title' _data/insights-videos.yaml) + guests=$(yq '.futurevideos[0].authors' _data/insights-videos.yaml) + + date_raw=$(yq '.futurevideos[0].date' _data/insights-videos.yaml) + date_iso=$(date --date="$date_raw" +"%Y-%m-%d") + date=${date_iso}T13:00Z + + yq -i '.nextsessiontitle = "'"$title"'"' _data/insights-videos.yaml + yq -i '.nextsessionguest = "'"$guests"'"' _data/insights-videos.yaml + yq -i '.nextsessiondate = "'"$date"'"' _data/insights-videos.yaml + + - name: Commit and Create Pull Request + if: steps.archive_session.outputs.title != '' + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + git config --local user.name "Action user" + git config --global user.email "actionuser@foo" + + branch_name="feat/update-sessions-$(date +'%Y%m%d%H%M')" + git checkout -b "$branch_name" + + git add _data/insights-videos.yaml + git commit -m "[Insights sessions] move '${{ steps.archive_session.outputs.title }}' to archive" + + # Push the new branch + git push -u origin "$branch_name" + + # Create a pull request using the GitHub CLI + gh pr create --title "[Insights sessions] move '${{ steps.archive_session.outputs.title }}' to archive" \ + --body "Automated Quarkus Insights session update." \ + --base main \ + --head "$branch_name" \ + --repo "github.com/marko-bekhta/quarkusio.github.io" diff --git a/_data/insights-videos.yaml b/_data/insights-videos.yaml index 30197ffa4f..8c5fde2052 100644 --- a/_data/insights-videos.yaml +++ b/_data/insights-videos.yaml @@ -4,15 +4,11 @@ sectiontitle: "Upcoming Podcast" socialdescription: "View the Podcast on these platforms" futureheadline: "Scheduled Podcasts" # Next upcoming session (update weekly) -nextsessiontitle: "EPISODE #220: Virtual Threads vs Reactive Programming in Quarkus" -nextsessiondate: "2025-09-29T13:00Z" -nextsessionguest: "Willem Jan Glerum" +nextsessiontitle: "EPISODE #221: Back to basics with Observability - Part 2" +nextsessiondate: "2025-10-06T13:00Z" +nextsessionguest: "Bruno Baptista" # upcoming session list (update weekly) futurevideos: - - title: "EPISODE #220: Virtual Threads vs Reactive Programming in Quarkus" - link: - date: "September 29, 2025" - authors: "Willem Jan Glerum" - title: "EPISODE #221: Back to basics with Observability - Part 2" link: date: "October 6, 2025" @@ -40,6 +36,10 @@ futurevideos: # past session list (move last upcoming to this list weekly) pastheadline: "Archived Podcast Videos" pastvideos: + - title: 'EPISODE #220: Virtual Threads vs Reactive Programming in Quarkus' + date: September 29, 2025 + authors: Willem Jan Glerum + link: https://www.youtube.com/watch?v=YX7NJxOUMWU - title: "EPISODE #219: Quarkus Loves Hibernate: ORM and Reactive Together" link: https://youtube.com/live/aFMOGThAoQU date: "September 22, 2025"