Skip to content
This repository has been archived by the owner on Jul 14, 2022. It is now read-only.

feat: add Twitter post notification on new blog article #54

Closed
wants to merge 2 commits into from
Closed
Changes from 1 commit
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
35 changes: 35 additions & 0 deletions .github/workflows/blog-deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -99,3 +99,38 @@ jobs:
to: ${{ secrets.TELEGRAM_OSSCAMEROON_CHANNEL_ID }}
token: ${{ secrets.TELEGRAM_BOT_TOKEN }}
message_file: message
- name: Get tweet content
dev-liro marked this conversation as resolved.
Show resolved Hide resolved
run: |
find ./content/post -name '*.md' | sort | uniq > current_branch_files
CURRENT_BRANCH_FILES=$(cat current_branch_files)
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git config --global user.name "github-actions[bot]"
git stash && git checkout HEAD~ && git clean -fdx && \
find ./content/post -name '*.md' | sort | uniq > previous_branch_files
PREVIOUS_BRANCH_FILES=$(cat previous_branch_files)
echo "current_branch_files=$CURRENT_BRANCH_FILES"
echo "========================================="
echo "previous_branch_files=$PREVIOUS_BRANCH_FILES"
echo "++++++++++++++++++++++++++++++++++++++++++++"
echo "$CURRENT_BRANCH_FILES" > current_branch_files

set +e
POTENTIAL_ARTICLES=$(diff current_branch_files previous_branch_files | grep "content" | sed 's/[<>] //g')
set -e

#Fail if there was no potential articles found
test ! -z "$POTENTIAL_ARTICLES"
echo "message<<EOF" >> $GITHUB_ENV
echo "Checkout this article on our blog." >> $GITHUB_ENV
for article in $POTENTIAL_ARTICLES; do
echo "> https://blog.osscameroon.com$(echo $article | sed "s/\.md//g; s/^\.\/content//g")" >> $GITHUB_ENV
done
echo "EOF" >> $GITHUB_ENV
Comment on lines +104 to +128
Copy link
Member

@Sanix-Darker Sanix-Darker Jan 12, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Optional suggestion:
I will suggest to add this inside a bash script following the example made on 'notify_on_pull_request', so that this file will doesn't get too fat ('blog-deploy/blog-deploy.sh')...

What do you think ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay

- name: Send tweet when new blog article is created
uses: devigned/go-twitter-action@v1
with:
message: ${{ env.message }}
apiKey: ${{ secrets.TWITTER_CONSUMER_API_KEY }}
apiKeySecret: ${{ secrets.TWITTER_CONSUMER_API_SECRET }}
accessToken: ${{ secrets.TWITTER_ACCESS_TOKEN }}
accessTokenSecret: ${{ secrets.TWITTER_ACCESS_TOKEN_SECRET }}