Skip to content

Commit bcf0020

Browse files
committed
fix: address codex review findings (pass 1)
- Use full push range instead of HEAD~1 to catch multi-commit pushes - Skip deleted files before reading frontmatter - Use --diff-filter=A to only tweet newly added posts, not edits
1 parent d992da1 commit bcf0020

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

.github/workflows/tweet.yml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,17 @@ jobs:
1313
steps:
1414
- uses: actions/checkout@v4
1515
with:
16-
fetch-depth: 2
16+
fetch-depth: 0
1717

18-
- name: Find changed blog posts
18+
- name: Find new blog posts
1919
id: changed
2020
run: |
21-
changed=$(git diff --name-only HEAD~1 HEAD -- 'content/*/module.md' | grep -v '^content/docs' || true)
21+
changed=$(git diff --name-only --diff-filter=A ${{ github.event.before }}..${{ github.sha }} -- 'content/*/module.md' | grep -v '^content/docs' || true)
2222
echo "files<<EOF" >> "$GITHUB_OUTPUT"
2323
echo "$changed" >> "$GITHUB_OUTPUT"
2424
echo "EOF" >> "$GITHUB_OUTPUT"
2525
26-
- name: Tweet changed posts
26+
- name: Tweet new posts
2727
if: steps.changed.outputs.files != ''
2828
env:
2929
X_API_KEY: ${{ secrets.X_API_KEY }}
@@ -33,6 +33,10 @@ jobs:
3333
run: |
3434
echo "${{ steps.changed.outputs.files }}" | while IFS= read -r file; do
3535
if [[ -z "$file" ]]; then continue; fi
36+
if [[ ! -f "$file" ]]; then
37+
echo "Skipping $file — file does not exist"
38+
continue
39+
fi
3640
slug=$(basename "$(dirname "$file")")
3741
tweet_field=$(awk '/<details>/{f=1;next} /<\/details>/{if(f)exit} f' "$file" | grep '^tweet:' | head -1)
3842
if [[ -z "$tweet_field" ]]; then

0 commit comments

Comments
 (0)