Skip to content

Commit

Permalink
fix(ci): publish post creation eventtype logic
Browse files Browse the repository at this point in the history
  • Loading branch information
leo-the-nardo committed Dec 6, 2024
1 parent 7956b70 commit 2bd4e54
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/publish-posts-updated-gcp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,4 @@ jobs:
GCP_PROJECT_ID: ${{ secrets.GCP_PROJECT_ID }}
GCP_TOPIC_NAME: ${{ env.GCP_TOPIC_NAME }}
CHANGED_FILES: ${{ env.CHANGED_FILES }}
run: node github-actions-scripts/publish-post-update.js
run: node ci-scripts/publish-post-update.js
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,17 @@ function extractFrontmatter(filePath) {
function determineEventType(filePath) {
const slug = path.basename(filePath, '.mdx');
try {
const creationOutput = execSync(`git log --diff-filter=A -- ${filePath}`).toString().trim();
const creationOutput = execSync(`git diff --diff-filter=M --name-only HEAD~1`).toString().trim().includes(filePath);
if (creationOutput) {
return 'POST_CREATED';
}

if (!fs.existsSync(filePath)) {
return 'POST_DELETED';
}

const diffOutput = execSync(`git diff HEAD~1 HEAD -- ${filePath}`).toString().trim();
if (diffOutput.includes('title') || diffOutput.includes('tags') || diffOutput.includes('description')) {
return 'META_UPDATED';
}

return 'CONTENT_UPDATED';
} catch (error) {
console.error(`Error determining event type for ${slug}:`, error);
Expand Down

0 comments on commit 2bd4e54

Please sign in to comment.