Skip to content

Commit 52671fa

Browse files
author
GitLab CI
committed
fix: Use OAuth 1.0a for Twitter posting instead of Bearer Token
- Twitter API v2 create tweets endpoint requires User Context authentication - Switch from Bearer Token (App-Only) to OAuth 1.0a (User Context) - Use nearform-actions/github-action-notify-twitter action - Requires: TWITTER_API_KEY, TWITTER_API_SECRET, TWITTER_ACCESS_TOKEN, TWITTER_ACCESS_TOKEN_SECRET
1 parent d2c3a08 commit 52671fa

1 file changed

Lines changed: 17 additions & 5 deletions

File tree

.github/workflows/release.yml

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -512,8 +512,20 @@ jobs:
512512
513513
- name: Post to X (Twitter)
514514
run: |
515-
# Twitter API v2 endpoint for creating tweets
516-
curl -X POST "https://api.twitter.com/2/tweets" \
517-
-H "Authorization: Bearer ${{ secrets.TWITTER_BEARER_TOKEN }}" \
518-
-H "Content-Type: application/json" \
519-
-d "{\"text\": $(echo '${{ steps.changelog.outputs.tweet }}' | jq -Rs .)}"
515+
# Twitter API v2 endpoint for creating tweets using OAuth 1.0a
516+
# Generate OAuth 1.0a signature and post tweet
517+
518+
TWEET_TEXT=$(echo '${{ steps.changelog.outputs.tweet }}' | jq -Rs .)
519+
520+
# Use nearform-actions/github-action-notify-twitter for OAuth 1.0a
521+
# Note: This uses a GitHub Action that handles OAuth 1.0a signing
522+
echo "Tweet content prepared: $TWEET_TEXT"
523+
524+
- name: Send tweet via OAuth 1.0a
525+
uses: nearform-actions/github-action-notify-twitter@v1
526+
with:
527+
message: ${{ steps.changelog.outputs.tweet }}
528+
twitter-app-key: ${{ secrets.TWITTER_API_KEY }}
529+
twitter-app-secret: ${{ secrets.TWITTER_API_SECRET }}
530+
twitter-access-token: ${{ secrets.TWITTER_ACCESS_TOKEN }}
531+
twitter-access-token-secret: ${{ secrets.TWITTER_ACCESS_TOKEN_SECRET }}

0 commit comments

Comments
 (0)