From 0f80e52d24ea11608bbbc222bac54749b35be24b Mon Sep 17 00:00:00 2001 From: Sumit Singh Date: Tue, 27 Dec 2022 13:28:15 +0530 Subject: [PATCH 01/16] test gh action --- .github/workflows/mastodon-post.yml | 28 ++++++++++++++++++++++++++++ content/posts/test-github-action.md | 1 + 2 files changed, 29 insertions(+) create mode 100644 .github/workflows/mastodon-post.yml create mode 100644 content/posts/test-github-action.md diff --git a/.github/workflows/mastodon-post.yml b/.github/workflows/mastodon-post.yml new file mode 100644 index 0000000..ccb4820 --- /dev/null +++ b/.github/workflows/mastodon-post.yml @@ -0,0 +1,28 @@ +name: Send a toot to Mastodon when you post a new blog post + +on: [pull_request] + +jobs: + post: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-python@v4 + with: + python-version: '3.11' + - run: pip install requests + + - name: Setup tmate session + uses: mxschmitt/action-tmate@v3 + timeout-minutes: 15 + + - name: Post to Mastodon + uses: sumit4613/post-to-mastodon@master + 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" \ No newline at end of file diff --git a/content/posts/test-github-action.md b/content/posts/test-github-action.md new file mode 100644 index 0000000..eac74df --- /dev/null +++ b/content/posts/test-github-action.md @@ -0,0 +1 @@ +# Just testing github action \ No newline at end of file From f45e9a8fdf0fcf32549d7216eb1f809a1536b4bf Mon Sep 17 00:00:00 2001 From: Sumit Singh Date: Tue, 27 Dec 2022 13:30:51 +0530 Subject: [PATCH 02/16] use correct name --- .github/workflows/mastodon-post.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/mastodon-post.yml b/.github/workflows/mastodon-post.yml index ccb4820..0a790d5 100644 --- a/.github/workflows/mastodon-post.yml +++ b/.github/workflows/mastodon-post.yml @@ -17,7 +17,7 @@ jobs: timeout-minutes: 15 - name: Post to Mastodon - uses: sumit4613/post-to-mastodon@master + 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!" From 86e11076c43746283e5f227a183cb49de853c0a7 Mon Sep 17 00:00:00 2001 From: Sumit Singh Date: Tue, 27 Dec 2022 14:27:40 +0530 Subject: [PATCH 03/16] publish action --- .github/workflows/mastodon-post.yml | 6 ++++-- content/posts/test-github-action.md | 6 +++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/.github/workflows/mastodon-post.yml b/.github/workflows/mastodon-post.yml index 0a790d5..24c3162 100644 --- a/.github/workflows/mastodon-post.yml +++ b/.github/workflows/mastodon-post.yml @@ -10,11 +10,13 @@ jobs: - uses: actions/setup-python@v4 with: python-version: '3.11' - - run: pip install requests + - name: Logging + run: | + echo "${{toJSON(github.event)}}" - name: Setup tmate session uses: mxschmitt/action-tmate@v3 - timeout-minutes: 15 + timeout-minutes: 30 - name: Post to Mastodon uses: sumit4613/post-to-mastodon@main diff --git a/content/posts/test-github-action.md b/content/posts/test-github-action.md index eac74df..385f1a6 100644 --- a/content/posts/test-github-action.md +++ b/content/posts/test-github-action.md @@ -1 +1,5 @@ -# Just testing github action \ No newline at end of file +# Just testing github action + +new change + +another change \ No newline at end of file From 78051a6b664c2ff6cdf8779b0afd843e0601d64f Mon Sep 17 00:00:00 2001 From: Sumit Singh Date: Wed, 28 Dec 2022 11:09:08 +0530 Subject: [PATCH 04/16] fetch depth --- .github/workflows/mastodon-post.yml | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/.github/workflows/mastodon-post.yml b/.github/workflows/mastodon-post.yml index 24c3162..7a44a18 100644 --- a/.github/workflows/mastodon-post.yml +++ b/.github/workflows/mastodon-post.yml @@ -7,13 +7,8 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - - uses: actions/setup-python@v4 with: - python-version: '3.11' - - name: Logging - run: | - echo "${{toJSON(github.event)}}" - + fetch-depth: 0 - name: Setup tmate session uses: mxschmitt/action-tmate@v3 timeout-minutes: 30 From dbfc43e476c75d393d8122a6938dd9306f92e83e Mon Sep 17 00:00:00 2001 From: Sumit Singh Date: Wed, 28 Dec 2022 11:56:15 +0530 Subject: [PATCH 05/16] use git --- .github/workflows/mastodon-post.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/mastodon-post.yml b/.github/workflows/mastodon-post.yml index 7a44a18..b28ca30 100644 --- a/.github/workflows/mastodon-post.yml +++ b/.github/workflows/mastodon-post.yml @@ -9,9 +9,13 @@ jobs: - uses: actions/checkout@v3 with: fetch-depth: 0 + - name: log recently added files + run: | + git log -1 --stat --grep=publish --oneline >> $RECENTLY_ADDED_FILES + - name: Setup tmate session uses: mxschmitt/action-tmate@v3 - timeout-minutes: 30 + timeout-minutes: 10 - name: Post to Mastodon uses: sumit4613/post-to-mastodon@main From ddc0ba4205f0b35d3f1735d6e4a2ebdaa9acee82 Mon Sep 17 00:00:00 2001 From: Sumit Singh Date: Wed, 28 Dec 2022 11:58:48 +0530 Subject: [PATCH 06/16] fix variable name --- .github/workflows/mastodon-post.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/mastodon-post.yml b/.github/workflows/mastodon-post.yml index b28ca30..fc4f8ca 100644 --- a/.github/workflows/mastodon-post.yml +++ b/.github/workflows/mastodon-post.yml @@ -11,7 +11,7 @@ jobs: fetch-depth: 0 - name: log recently added files run: | - git log -1 --stat --grep=publish --oneline >> $RECENTLY_ADDED_FILES + git log -1 --stat --grep=publish --oneline >> "${RECENTLY_ADDED_FILES}" - name: Setup tmate session uses: mxschmitt/action-tmate@v3 From 21a38eb709422f6c12aac1f2af8aa57c1354823a Mon Sep 17 00:00:00 2001 From: Sumit Singh Date: Wed, 28 Dec 2022 12:04:56 +0530 Subject: [PATCH 07/16] fix variable name --- .github/workflows/mastodon-post.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/mastodon-post.yml b/.github/workflows/mastodon-post.yml index fc4f8ca..df458ad 100644 --- a/.github/workflows/mastodon-post.yml +++ b/.github/workflows/mastodon-post.yml @@ -8,9 +8,9 @@ jobs: steps: - uses: actions/checkout@v3 with: - fetch-depth: 0 - - name: log recently added files + fetch-depth: '0' run: | + git checkout HEAD^ git log -1 --stat --grep=publish --oneline >> "${RECENTLY_ADDED_FILES}" - name: Setup tmate session From 59eccaa5c564344b655dda2a265f430f00641615 Mon Sep 17 00:00:00 2001 From: Sumit Singh Date: Wed, 28 Dec 2022 12:08:08 +0530 Subject: [PATCH 08/16] fix --- .github/workflows/mastodon-post.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/mastodon-post.yml b/.github/workflows/mastodon-post.yml index df458ad..6404fdb 100644 --- a/.github/workflows/mastodon-post.yml +++ b/.github/workflows/mastodon-post.yml @@ -9,7 +9,7 @@ jobs: - uses: actions/checkout@v3 with: fetch-depth: '0' - run: | + - run: | git checkout HEAD^ git log -1 --stat --grep=publish --oneline >> "${RECENTLY_ADDED_FILES}" From dd4b8c727bdcbb1e2568c99e78f1c51c3da2e8cd Mon Sep 17 00:00:00 2001 From: Sumit Singh Date: Wed, 28 Dec 2022 12:15:31 +0530 Subject: [PATCH 09/16] fix --- .github/workflows/mastodon-post.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/mastodon-post.yml b/.github/workflows/mastodon-post.yml index 6404fdb..a62a301 100644 --- a/.github/workflows/mastodon-post.yml +++ b/.github/workflows/mastodon-post.yml @@ -11,7 +11,7 @@ jobs: fetch-depth: '0' - run: | git checkout HEAD^ - git log -1 --stat --grep=publish --oneline >> "${RECENTLY_ADDED_FILES}" + RECENTLY_ADDED_FILES=$(git log -1 --stat --grep=publish --oneline) - name: Setup tmate session uses: mxschmitt/action-tmate@v3 From 28f3415cddc2ac9488b7fe638a6df53f073e2eb6 Mon Sep 17 00:00:00 2001 From: Sumit Singh Date: Wed, 28 Dec 2022 12:25:52 +0530 Subject: [PATCH 10/16] another fix --- .github/workflows/mastodon-post.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/mastodon-post.yml b/.github/workflows/mastodon-post.yml index a62a301..ad8d079 100644 --- a/.github/workflows/mastodon-post.yml +++ b/.github/workflows/mastodon-post.yml @@ -10,9 +10,9 @@ jobs: with: fetch-depth: '0' - run: | - git checkout HEAD^ RECENTLY_ADDED_FILES=$(git log -1 --stat --grep=publish --oneline) - + 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 From 4be7e34c14f34680e677fa8232b8cefc7562f6c6 Mon Sep 17 00:00:00 2001 From: Sumit Singh Date: Wed, 28 Dec 2022 12:27:05 +0530 Subject: [PATCH 11/16] another fix --- .github/workflows/mastodon-post.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/mastodon-post.yml b/.github/workflows/mastodon-post.yml index ad8d079..fa0794d 100644 --- a/.github/workflows/mastodon-post.yml +++ b/.github/workflows/mastodon-post.yml @@ -12,7 +12,6 @@ jobs: - run: | RECENTLY_ADDED_FILES=$(git log -1 --stat --grep=publish --oneline) 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 From 6ccaf9c117f7157ccc8a77220b2dd7c486400750 Mon Sep 17 00:00:00 2001 From: Sumit Singh Date: Wed, 28 Dec 2022 12:33:37 +0530 Subject: [PATCH 12/16] another fix --- .github/workflows/mastodon-post.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/mastodon-post.yml b/.github/workflows/mastodon-post.yml index fa0794d..ad8d079 100644 --- a/.github/workflows/mastodon-post.yml +++ b/.github/workflows/mastodon-post.yml @@ -12,6 +12,7 @@ jobs: - run: | RECENTLY_ADDED_FILES=$(git log -1 --stat --grep=publish --oneline) 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 From 9930738dd8016ddf1dac5611163c257f4b5c3fb4 Mon Sep 17 00:00:00 2001 From: Sumit Singh Date: Wed, 28 Dec 2022 12:37:12 +0530 Subject: [PATCH 13/16] another fix --- .github/workflows/mastodon-post.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/mastodon-post.yml b/.github/workflows/mastodon-post.yml index ad8d079..ecf9cd7 100644 --- a/.github/workflows/mastodon-post.yml +++ b/.github/workflows/mastodon-post.yml @@ -10,7 +10,7 @@ jobs: with: fetch-depth: '0' - run: | - RECENTLY_ADDED_FILES=$(git log -1 --stat --grep=publish --oneline) + RECENTLY_ADDED_FILES=$(git log -1 --stat --grep=publish --oneline | tr '\n' ' ') echo $RECENTLY_ADDED_FILES echo "RECENTLY_ADDED_FILES=$RECENTLY_ADDED_FILES" >> $GITHUB_ENV - name: Setup tmate session From e7f55e46a930feb41b5d5b7f7e390d73903b1136 Mon Sep 17 00:00:00 2001 From: Sumit Singh Date: Wed, 28 Dec 2022 12:42:37 +0530 Subject: [PATCH 14/16] improvise --- .github/workflows/mastodon-post.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/mastodon-post.yml b/.github/workflows/mastodon-post.yml index ecf9cd7..73bf2b7 100644 --- a/.github/workflows/mastodon-post.yml +++ b/.github/workflows/mastodon-post.yml @@ -7,10 +7,8 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - with: - fetch-depth: '0' - run: | - RECENTLY_ADDED_FILES=$(git log -1 --stat --grep=publish --oneline | tr '\n' ' ') + 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 From 076f7f80721ebb0584c36ecf510374fb3216fbdf Mon Sep 17 00:00:00 2001 From: Sumit Singh Date: Wed, 28 Dec 2022 15:26:55 +0530 Subject: [PATCH 15/16] publish post and check action --- .github/workflows/mastodon-post.yml | 39 +++++++++++++++-------------- content/posts/test-github-action.md | 2 +- 2 files changed, 21 insertions(+), 20 deletions(-) diff --git a/.github/workflows/mastodon-post.yml b/.github/workflows/mastodon-post.yml index 73bf2b7..6ab6bc0 100644 --- a/.github/workflows/mastodon-post.yml +++ b/.github/workflows/mastodon-post.yml @@ -1,27 +1,28 @@ 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_HEAD_REF + git checkout $GITHUB_HEAD_REF + RECENTLY_ADDED_FILES=$(git log -1 --stat --oneline --name-only | 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" \ No newline at end of file + - 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" \ No newline at end of file diff --git a/content/posts/test-github-action.md b/content/posts/test-github-action.md index 385f1a6..c3125b7 100644 --- a/content/posts/test-github-action.md +++ b/content/posts/test-github-action.md @@ -2,4 +2,4 @@ new change -another change \ No newline at end of file +let's see if action works or not \ No newline at end of file From d8c8e41412f98b67bfdb24fd1e8b4008def014fd Mon Sep 17 00:00:00 2001 From: Sumit Singh Date: Wed, 28 Dec 2022 16:23:43 +0530 Subject: [PATCH 16/16] publish test-github-action --- .github/workflows/mastodon-post.yml | 2 +- content/posts/test-github-action.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/mastodon-post.yml b/.github/workflows/mastodon-post.yml index 6ab6bc0..fa92037 100644 --- a/.github/workflows/mastodon-post.yml +++ b/.github/workflows/mastodon-post.yml @@ -18,7 +18,7 @@ jobs: - name: Post to Mastodon - uses: sumit4613/post-to-mastodon@main + uses: sumit4613/post-to-mastodon@v0.1 with: message: "Hello, folks! I just posted a new blog post. Check it out!" base_blog_url: "https://sumit4613.github.io/posts/" diff --git a/content/posts/test-github-action.md b/content/posts/test-github-action.md index c3125b7..e8c6935 100644 --- a/content/posts/test-github-action.md +++ b/content/posts/test-github-action.md @@ -2,4 +2,4 @@ new change -let's see if action works or not \ No newline at end of file +another test change \ No newline at end of file