Skip to content

Commit 5bace13

Browse files
committed
GitHub Action: Changes to render-newsletter
Adjust/fix how find-modified-newsletter.sh identifies a new post
1 parent d798079 commit 5bace13

File tree

3 files changed

+13
-5
lines changed

3 files changed

+13
-5
lines changed

.github/actions/render-newsletter/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ function escapeData(s: string): string {
2020
}
2121

2222
function setOutput(key: string, val: string) {
23-
process.stdout.write(`::set-output name=${key}::${escapeData(val)}` + EOL);
23+
process.stdout.write(`::set-output name=${key}::${escapeData(val)}${EOL}`);
2424
}
2525

2626
const API_BASE = 'https://api.sendgrid.com/v3';

.github/workflows/find-modified-newsletter.sh

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
#!/bin/bash
22

3-
post_path="$(git log --pretty=format: --name-only -1 --diff-filter=A \
3+
# Find the latest commit that doesn't change the actions or workflows
4+
commit_hash=$(git log --pretty=format:%H -1 -- ':/!.github/*')
5+
6+
# Find new posts in the latest commit, if any
7+
post_path="$(git show --pretty=format: --name-only --diff-filter=A $commit_hash \
48
| grep '^_posts/' \
59
| head -n1)"
610

@@ -11,6 +15,8 @@ if [ -n "$post_path" ]; then
1115
fi
1216

1317
post_path="$repo_root/$post_path"
18+
19+
echo Found post: $post_path
1420
fi
1521

1622
echo "::set-output name=post_path::$post_path"

.github/workflows/send-newsletter.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,14 @@ jobs:
99
- run: ./.github/workflows/get_domain.sh
1010
shell: bash
1111
id: site-domain
12-
- run: ./.github/workflows/find-modified-newsletter.sh
13-
shell: bash
12+
- name: Find new post
1413
id: newsletter-path
15-
- uses: ./.github/actions/render-newsletter
14+
run: ./.github/workflows/find-modified-newsletter.sh
15+
shell: bash
16+
- name: Render newsletter
1617
if: ${{ steps.newsletter-path.outputs.post_path != '' }}
1718
id: newsletter
19+
uses: ./.github/actions/render-newsletter
1820
with:
1921
text_path: "${{ steps.newsletter-path.outputs.post_path }}"
2022
template_path: "./.github/workflows/newsletter_template.html"

0 commit comments

Comments
 (0)