diff --git a/dist/index.js b/dist/index.js index 15d5b57..762136e 100644 --- a/dist/index.js +++ b/dist/index.js @@ -1698,7 +1698,7 @@ const ARGOCD_SERVER_URL = core.getInput('argocd-server-url'); const ARGOCD_TOKEN = core.getInput('argocd-token'); const VERSION = core.getInput('argocd-version'); const ENV = core.getInput('environment'); -const PLAINTEXT = core.getInput('plaintext').toLowerCase() === "true"; +const PLAINTEXT = core.getInput('plaintext').toLowerCase() === 'true'; let EXTRA_CLI_ARGS = core.getInput('argocd-extra-cli-args'); if (PLAINTEXT) { EXTRA_CLI_ARGS += ' --plaintext'; @@ -1835,7 +1835,7 @@ _Updated at ${new Date().toLocaleString('en-US', { timeZone: 'America/Los_Angele octokit.rest.issues.deleteComment({ owner, repo, - comment_id: comment.id, + comment_id: comment.id }); } } @@ -1864,7 +1864,7 @@ function run() { core.info(`Found apps: ${apps.map(a => a.metadata.name).join(', ')}`); const diffs = []; yield asyncForEach(apps, (app) => __awaiter(this, void 0, void 0, function* () { - const command = `app diff ${app.metadata.name} --server-side-generate`; + const command = `app diff ${app.metadata.name} --server-side-generate --revision ${github.context.sha}`; try { core.info(`Running: argocd ${command}`); // ArgoCD app diff will exit 1 if there is a diff, so always catch, diff --git a/src/main.ts b/src/main.ts index 4452ae0..0c55b61 100644 --- a/src/main.ts +++ b/src/main.ts @@ -37,7 +37,7 @@ const ARGOCD_SERVER_URL = core.getInput('argocd-server-url'); const ARGOCD_TOKEN = core.getInput('argocd-token'); const VERSION = core.getInput('argocd-version'); const ENV = core.getInput('environment'); -const PLAINTEXT = core.getInput('plaintext').toLowerCase() === "true"; +const PLAINTEXT = core.getInput('plaintext').toLowerCase() === 'true'; let EXTRA_CLI_ARGS = core.getInput('argocd-extra-cli-args'); if (PLAINTEXT) { EXTRA_CLI_ARGS += ' --plaintext'; @@ -108,8 +108,9 @@ async function getApps(): Promise { } return (responseJson.items as App[]).filter(app => { - const targetRevision = app.spec.source.targetRevision - const targetPrimary = targetRevision === 'master' || targetRevision === 'main' || !targetRevision + const targetRevision = app.spec.source.targetRevision; + const targetPrimary = + targetRevision === 'master' || targetRevision === 'main' || !targetRevision; return ( app.spec.source.repoURL.includes( `${github.context.repo.owner}/${github.context.repo.repo}` @@ -135,10 +136,12 @@ async function postDiffComment(diffs: Diff[]): Promise { const commitLink = `https://github.com/${owner}/${repo}/pull/${github.context.issue.number}/commits/${sha}`; const shortCommitSha = String(sha).substr(0, 7); - const prefixHeader = `## ArgoCD Diff on ${ENV}` + const prefixHeader = `## ArgoCD Diff on ${ENV}`; const diffOutput = diffs.map( ({ app, diff, error }) => ` -App: [\`${app.metadata.name}\`](${protocol}://${ARGOCD_SERVER_URL}/applications/${app.metadata.name}) +App: [\`${app.metadata.name}\`](${protocol}://${ARGOCD_SERVER_URL}/applications/${ + app.metadata.name + }) YAML generation: ${error ? ' Error 🛑' : 'Success 🟢'} App sync status: ${app.status.sync.status === 'Synced' ? 'Synced ✅' : 'Out of Sync ⚠️ '} ${ @@ -195,11 +198,11 @@ _Updated at ${new Date().toLocaleString('en-US', { timeZone: 'America/Los_Angele // Delete stale comments for (const comment of commentsResponse.data) { if (comment.body?.includes(prefixHeader)) { - core.info(`deleting comment ${comment.id}`) + core.info(`deleting comment ${comment.id}`); octokit.rest.issues.deleteComment({ owner, repo, - comment_id: comment.id, + comment_id: comment.id }); } } @@ -232,7 +235,7 @@ async function run(): Promise { const diffs: Diff[] = []; await asyncForEach(apps, async app => { - const command = `app diff ${app.metadata.name} --server-side-generate`; + const command = `app diff ${app.metadata.name} --server-side-generate --revision ${github.context.sha}` try { core.info(`Running: argocd ${command}`); // ArgoCD app diff will exit 1 if there is a diff, so always catch,