diff --git a/.github/workflows/publish-posts-updated-gcp.yml b/.github/workflows/publish-posts-updated-gcp.yml index 1f81d73..ddec193 100644 --- a/.github/workflows/publish-posts-updated-gcp.yml +++ b/.github/workflows/publish-posts-updated-gcp.yml @@ -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 \ No newline at end of file + run: node ci-scripts/publish-post-update.js \ No newline at end of file diff --git a/github-actions-scripts/package-lock.json b/ci-scripts/package-lock.json similarity index 100% rename from github-actions-scripts/package-lock.json rename to ci-scripts/package-lock.json diff --git a/github-actions-scripts/package.json b/ci-scripts/package.json similarity index 100% rename from github-actions-scripts/package.json rename to ci-scripts/package.json diff --git a/github-actions-scripts/publish-post-update.js b/ci-scripts/publish-post-update.js similarity index 95% rename from github-actions-scripts/publish-post-update.js rename to ci-scripts/publish-post-update.js index ca3f6c8..0e466a0 100644 --- a/github-actions-scripts/publish-post-update.js +++ b/ci-scripts/publish-post-update.js @@ -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);