Skip to content

Commit

Permalink
publish post and check action
Browse files Browse the repository at this point in the history
  • Loading branch information
sumit4613 committed Dec 28, 2022
1 parent e7f55e4 commit 7d57314
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 20 deletions.
41 changes: 22 additions & 19 deletions .github/workflows/mastodon-post.yml
Original file line number Diff line number Diff line change
@@ -1,27 +1,30 @@
name: Send a toot to Mastodon when you post a new blog post

on: [pull_request]
on: [ pull_request ]

jobs:
post:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- run: |
RECENTLY_ADDED_FILES=$(git log -1 --stat --grep=publish --oneline --name-only | tr '\n' ' ')
echo $RECENTLY_ADDED_FILES
echo "RECENTLY_ADDED_FILES=$RECENTLY_ADDED_FILES" >> $GITHUB_ENV
- name: Setup tmate session
uses: mxschmitt/action-tmate@v3
timeout-minutes: 10
- uses: actions/checkout@v3
with:
fetch-depth: '0'
- run: |
echo $GITHUB_REF
echo $GITHUB_HEAD_REF
echo $GITHUB_BASE_REF
git checkout $GITHUB_BASE_REF
RECENTLY_ADDED_FILES=$(git log -1 --stat --oneline --name-only --pretty=format:'%s | %b' | tr '\n' ' ')
echo $RECENTLY_ADDED_FILES
echo "RECENTLY_ADDED_FILES=$RECENTLY_ADDED_FILES" >> $GITHUB_ENV
- name: Post to Mastodon
uses: sumit4613/post-to-mastodon@main
if: "contains(github.event.head_commit.message, 'publish')"
with:
message: "Hello, folks! I just posted a new blog post. Check it out!"
base-blog-url: "https://sumit4613.github.io/posts/"
access-token: ${{ secrets.MASTODON_ACCESS_TOKEN }}
host: "fosstodon.org"
port: "443"
api: "api/v1"
- name: Post to Mastodon
uses: sumit4613/post-to-mastodon@main
with:
message: "Hello, folks! I just posted a new blog post. Check it out!"
base_blog_url: "https://sumit4613.github.io/posts/"
access_token: ${{ secrets.MASTODON_ACCESS_TOKEN }}
host: "fosstodon.org"
port: "443"
api: "api/v1"
2 changes: 1 addition & 1 deletion content/posts/test-github-action.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

new change

another change
let's see if action works or not

0 comments on commit 7d57314

Please sign in to comment.