-
Notifications
You must be signed in to change notification settings - Fork 9
Automate x.com to twitter.com URL transformation in GitHub Actions #279
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
base: c11r/251026-1740-add-retweet-argentumveritas-chatinargentumveritasapp-etc-web3-crypto-blockchaingaming-9a564a
Are you sure you want to change the base?
Changes from 1 commit
83020c7
a292c96
db64ac7
df31933
b3ea8a7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
…ing token Co-authored-by: realcodywburns <13103499+realcodywburns@users.noreply.github.com>
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,31 @@ | ||||||||||||||||||||||||
| #!/bin/bash | ||||||||||||||||||||||||
| # Transform x.com URLs to twitter.com format in tweet files | ||||||||||||||||||||||||
| # This script is used by the GitHub Actions workflow to ensure compatibility | ||||||||||||||||||||||||
| # with the twitter-together action which only supports twitter.com URLs | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| set -e | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| echo "Starting URL transformation..." | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| # Find all tweet files and transform x.com URLs to twitter.com | ||||||||||||||||||||||||
| find tweets -name "*.tweet" -type f -exec sed -i 's|https://x\.com/|https://twitter.com/|g' {} + | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
| find tweets -name "*.tweet" -type f -exec sed -i 's|https://x\.com/|https://twitter.com/|g' {} + | |
| find tweets -name "*.tweet" -type f -exec sed -i 's|https://x\.com/|https://twitter.com/|g' {} + || true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ack. This will be useful in cases like the current pr where the code is not a new tweet and the check is un necessarily blocking
Copilot
AI
Oct 29, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The git push command will fail in the pull_request_target context. When the preview job checks out github.event.pull_request.head.sha, it results in a detached HEAD state without a proper branch reference. Additionally, for external contributors, the workflow cannot push to their fork. Consider removing automatic commits from the preview job and only performing transformations in the tweet job when merging to main, or implement a different approach such as commenting on the PR to request manual fixes.
| # Configure git user | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| # Commit and push changes | |
| git add tweets/ | |
| git commit -m "Auto-transform x.com URLs to twitter.com format [skip ci]" | |
| git push | |
| echo "Changes committed and pushed" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The intent of using sha was to ensure we were retrieving the correct. If the transformation is only for the push to main this will make sense. We should have the action remind the team of this in the pr before the final push to main if feasible
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -12,27 +12,10 @@ jobs: | |||||||||
| - name: checkout pull request | ||||||||||
| uses: actions/checkout@v3 | ||||||||||
| with: | ||||||||||
| ref: ${{ github.event.pull_request.head.ref }} | ||||||||||
| repository: ${{ github.event.pull_request.head.repo.full_name }} | ||||||||||
| ref: ${{ github.event.pull_request.head.sha }} | ||||||||||
| token: ${{ secrets.GITHUB_TOKEN }} | ||||||||||
| - name: Transform x.com URLs to twitter.com | ||||||||||
| id: transform | ||||||||||
| run: | | ||||||||||
| echo "Starting URL transformation..." | ||||||||||
| find tweets -name "*.tweet" -type f -exec sed -i 's|https://x\.com/|https://twitter.com/|g' {} + | ||||||||||
|
|
||||||||||
| if git diff --quiet; then | ||||||||||
| echo "transformed=false" >> $GITHUB_OUTPUT | ||||||||||
| echo "No URL transformations needed" | ||||||||||
| else | ||||||||||
| echo "transformed=true" >> $GITHUB_OUTPUT | ||||||||||
| echo "Transformed x.com URLs to twitter.com" | ||||||||||
| git config user.name "github-actions[bot]" | ||||||||||
| git config user.email "github-actions[bot]@users.noreply.github.com" | ||||||||||
| git add tweets/ | ||||||||||
| git commit -m "Auto-transform x.com URLs to twitter.com format [skip ci]" | ||||||||||
| git push | ||||||||||
| fi | ||||||||||
| run: bash .github/scripts/transform-urls.sh | ||||||||||
| - name: Validate Tweets | ||||||||||
| uses: IstoraMandiri/twitter-together@etc | ||||||||||
| env: | ||||||||||
|
|
@@ -44,19 +27,10 @@ jobs: | |||||||||
| steps: | ||||||||||
| - name: checkout main | ||||||||||
| uses: actions/checkout@v3 | ||||||||||
|
||||||||||
| uses: actions/checkout@v3 | |
| uses: actions/checkout@v3 | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] Consider using
#!/usr/bin/env bashinstead of#!/bin/bashfor better portability across different systems where bash might be installed in different locations.