Skip to content

Post New Blog to LinkedIn #9

Post New Blog to LinkedIn

Post New Blog to LinkedIn #9

name: Post New Blog to LinkedIn
on:
workflow_run:
workflows: ["Scheduled Deploy"]
types:
- completed
schedule:
# 8:15 AM Eastern (15 min after Bluesky to stagger)
- cron: '15 13 * * *'
workflow_dispatch:
inputs:
target_date:
description: 'Date to look for posts (YYYY-MM-DD). Defaults to current date.'
required: false
type: string
jobs:
check-trigger:
runs-on: ubuntu-latest
outputs:
should_continue: ${{ steps.check.outputs.should_continue }}
steps:
- name: Check if we should continue
id: check
run: |
if [ "${{ github.event_name }}" == "workflow_run" ]; then
if [ "${{ github.event.workflow_run.conclusion }}" != "success" ]; then
echo "Scheduled Deploy failed, skipping"
echo "should_continue=false" >> $GITHUB_OUTPUT
exit 0
fi
fi
echo "should_continue=true" >> $GITHUB_OUTPUT
detect:
needs: check-trigger
if: needs.check-trigger.outputs.should_continue == 'true'
uses: CodingWithCalvin/.github/.github/workflows/detect-blog-post-from-rss.yml@main
with:
rss_url: 'https://www.codingwithcalvin.net/rss.xml'
target_date: ${{ inputs.target_date }}
notify:
needs: detect
if: needs.detect.outputs.has_posts == 'true'
uses: CodingWithCalvin/.github/.github/workflows/linkedin-post.yml@main
with:
post_text: |
New Blog Post!
${{ needs.detect.outputs.post_title }}
${{ needs.detect.outputs.post_hashtags }}
article_url: ${{ needs.detect.outputs.post_url }}
article_title: ${{ needs.detect.outputs.post_title }}
article_description: ${{ needs.detect.outputs.post_description }}
secrets:
LINKEDIN_ACCESS_TOKEN: ${{ secrets.LINKEDIN_ACCESS_TOKEN }}
LINKEDIN_CLIENT_ID: ${{ secrets.LINKEDIN_CLIENT_ID }}