diff --git a/.github/workflows/social-networks.yml b/.github/workflows/social-networks.yml index fec60585..506ea181 100644 --- a/.github/workflows/social-networks.yml +++ b/.github/workflows/social-networks.yml @@ -23,12 +23,12 @@ on: workflow_dispatch: inputs: release_body: - description: 'The body of the release notes (leave empty to use latest release)' + description: 'The body of the release notes' required: false type: string default: '' release_tag: - description: 'The tag of the release (leave empty to use latest release tag)' + description: 'The tag of the release' required: false type: string default: '' @@ -53,6 +53,29 @@ jobs: echo "$TRUNCATED_BODY" >> $GITHUB_OUTPUT echo "EOF" >> $GITHUB_OUTPUT + - name: Grab image from release body + id: grab_image + env: + RELEASE_BODY: ${{ inputs.release_body || github.event.release.body }} + run: | + # Extract src URLs and alt values + URLS=$(echo "$RELEASE_BODY" | grep -oP ']+src="\K[^"]+' | paste -sd',') + ALTS=$(echo "$RELEASE_BODY" | grep -oP ']+alt="\K[^"]+' | paste -sd',') + + # Download images into workspace using relative paths (Docker actions mount GITHUB_WORKSPACE, not /tmp) + mkdir -p ".release-images" + LOCAL_PATHS="" + IFS=',' read -ra URL_LIST <<< "$URLS" + for url in "${URL_LIST[@]}"; do + filename="${url##*/}.png" + curl -sSL "$url" -o ".release-images/$filename" + LOCAL_PATHS="${LOCAL_PATHS:+$LOCAL_PATHS,}.release-images/$filename" + ls -lah ".release-images/$filename" + done + + echo "image_paths=$LOCAL_PATHS" | tee -a "$GITHUB_OUTPUT" + echo "image_alt_texts=$ALTS" | tee -a "$GITHUB_OUTPUT" + - name: Send post to Bluesky id: post2bluesky uses: cbrgm/bluesky-github-action@v1 # https://github.com/marketplace/actions/bluesky-send-post @@ -66,6 +89,8 @@ jobs: ${{ steps.prepare_body.outputs.truncated_body }} #fish #shell #release lang: "en" + image-paths: ${{ steps.grab_image.outputs.image_paths }} # Comma-separated list of image paths to include in the post + image-alt-texts: ${{ steps.grab_image.outputs.image_alt_texts }} # Comma-separated list of image alt texts - name: Post to Mastodon (Piaille.fr) id: post2paille @@ -83,3 +108,5 @@ jobs: ${{ steps.prepare_body.outputs.truncated_body }} #fish #shell #release language: "en" + image-paths: ${{ steps.grab_image.outputs.image_paths }} # Comma-separated list of image paths to include in the post + image-alt-texts: ${{ steps.grab_image.outputs.image_alt_texts }} # Comma-separated list of image alt texts