Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable GitAuto to draft a X post when a PR is merged to provide real time updates to followers #397

Merged
merged 1 commit into from
Dec 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions .github/workflows/x-post-draft.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Create X Post Draft

on:
pull_request:
types: [closed]
branches:
- main

jobs:
create-x-post-draft:
if: github.event.pull_request.merged == true
runs-on: ubuntu-latest
steps:
# https://github.com/actions/checkout
- uses: actions/checkout@v4

# https://github.com/actions/setup-node
- uses: actions/setup-node@v4
with:
node-version: '20' # Updated to latest LTS version

# https://github.com/plhery/node-twitter-api-v2
- name: Install dependencies
run: npm install twitter-api-v2

# https://github.com/actions/github-script
- name: Create X Post Draft
uses: actions/github-script@v7
with:
script: |
const { TwitterApi } = require('twitter-api-v2');

// Initialize with bearer token
const client = new TwitterApi(process.env.TWITTER_BEARER_TOKEN);

const tweet = `🚀 New merge: ${context.payload.pull_request.title}\n\n${context.payload.pull_request.html_url}`;

await client.v2.tweet(tweet, { draft_mode: true });
hiroshinishio marked this conversation as resolved.
Show resolved Hide resolved
env:
TWITTER_BEARER_TOKEN: ${{ secrets.TWITTER_BEARER_TOKEN }}

Loading