Each time I create a new post in my Jekyll website, I would like to create automatically a tweet in twitter and a post in a facebook group.
Does a plugin exists or something like this to perform that ?
I don’t know about FB, but you can use the Twitter API.
GitHub Actions is great for this kind of automation. You could set it up to listen for changes to master directory in the
_posts dir and then have a Python script find the last changed file (according to date from filename or git added date etc.) and tweet a link to it.
There are premade Twitter actions in the GH Actions marketplace which can help you with this. Then you could write a shell / Python script which finds the appropriate file and builds the URL, then pass that value to the Action so it tweets a given message.
Or you could write a Python script that identifies the appropriate file and URL and tweets.
I have a template here
Oh and if it helps to get started, you might want to post a tweet that goes to your blog homepage or
/blog page, as that saves you having to generate full URL to the page.
This could be possible using a Jekyll plugin written in Ruby. Except, Jekyll builds are not stateful. When you run Jekyll locally or in the cloud repeatedly, it might tweet for a post that was created with today’s date, but how does it know when its done? If you rebuild a 2nd time locally, or your build locally and then on the remote, will it tweet twice?
GH Actions seems nice here, as it is sits outside your Jekyll code and listens for changes to a directory. And the logic could be in Ruby or Python or Bash or whatever. Though, there’s still the challenge of how do you make sure that when you edit the post multiple times, that you don’t get GH Actions to make tweet for each edit. Unless you keep a file somewhere in the repo of posts that have been tweeted, and then update that file during the CI flow after tweeting.
It is far easier to just make a CI flow which tweets a link to your posts listing page when you create a tag or release or github. Because you’ll only create the release once and then not make new releases presumably based on just edits. That flow simple - it just takes a manual step to make the release.
Sorry - no simple / easy solution here to recommend. I don’t think this is a common use-case.
You speak chinese for me !!!
Sorry. Well no plugins that I have seen.
But GitHub Actions will let you do something on GitHub like when making a commit.
e.g. Here is an Action that will make a tweet for you
The actual part of figuring out the URL to tweet and not tweeting it too much is harder.
Regardless of using Python or a Ruby plugin, or GitHub Actions, you need to register for a dev account on Twitter with a motivation and wait for them to approve you. So it’s not just plug and play
Maybe just settle for a manual process.