Skip to content

Commit

Permalink
use --revision
Browse files Browse the repository at this point in the history
  • Loading branch information
aaron-weisberg-qz committed Jul 19, 2024
1 parent 3a7d973 commit 85fddba
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
6 changes: 3 additions & 3 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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
});
}
}
Expand Down Expand Up @@ -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,
Expand Down
19 changes: 11 additions & 8 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -108,8 +108,9 @@ async function getApps(): Promise<App[]> {
}

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}`
Expand All @@ -135,10 +136,12 @@ async function postDiffComment(diffs: Diff[]): Promise<void> {
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 ⚠️ '}
${
Expand Down Expand Up @@ -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
});
}
}
Expand Down Expand Up @@ -232,7 +235,7 @@ async function run(): Promise<void> {
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,
Expand Down

0 comments on commit 85fddba

Please sign in to comment.