From b28f1a24bab98e9a6c1e3be43bc99c56c9c77f1d Mon Sep 17 00:00:00 2001 From: Elie Dutheil Date: Mon, 7 Aug 2023 16:51:18 +0200 Subject: [PATCH] :construction_worker: Migrate default branch from master to main --- .github/workflows/test.yml | 2 +- README.md | 10 +++++----- dist/index.js | 32 ++++++++++++++++---------------- src/main.ts | 8 ++++---- 4 files changed, 26 insertions(+), 26 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 0d000e0..7df940b 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -3,7 +3,7 @@ on: # rebuild any PRs and main branch changes pull_request: push: branches: - - master + - main - 'releases/*' jobs: diff --git a/README.md b/README.md index 1dc731c..5c1cb7e 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@ # ArgoCD Diff GitHub Action -This action generates a diff between the current PR and the current state of the cluster. +This action generates a diff between the current PR and the current state of the cluster. -Note that this includes any changes between your branch and latest `master`, as well as ways in which the cluster is out of sync. +Note that this includes any changes between your branch and latest `main`, as well as ways in which the cluster is out of sync. This is a fork of the original [argocd-diff-action](https://github.com/quizlet/argocd-diff-action) repository. This fork was created to update the github action in order for it to work with more recent versions of ArgoCD by removing the API call to get the list of ArgoCD apps and using the CLI instead. @@ -14,7 +14,7 @@ name: ArgoCD Diff on: pull_request: - branches: [master, main] + branches: [main] jobs: argocd-diff: @@ -25,7 +25,7 @@ jobs: - name: Checkout repo uses: actions/checkout@v2 - - uses: lalalilo/argocd-diff-action@master + - uses: lalalilo/argocd-diff-action@main name: ArgoCD Diff with: argocd-server-url: argocd.example.com @@ -39,7 +39,7 @@ jobs: 1. Downloads the specified version of the ArgoCD binary, and makes it executable 2. Uses the binary to run `argocd app list` to get all the apps associated with the current repository -3. Filters the apps to only keep the ones synced to `master` or `main` branches +3. Filters the apps to only keep the ones synced to `main` branch 4. Runs `argocd app diff` for each app 5. Posts the diff output as a comment on the PR diff --git a/dist/index.js b/dist/index.js index 2d17dee..5763bb4 100644 --- a/dist/index.js +++ b/dist/index.js @@ -556,8 +556,8 @@ class OidcClient { const res = yield httpclient .getJson(id_token_url) .catch(error => { - throw new Error(`Failed to get ID Token. \n - Error Code : ${error.statusCode}\n + throw new Error(`Failed to get ID Token. \n + Error Code : ${error.statusCode}\n Error Message: ${error.result.message}`); }); const id_token = (_a = res.result) === null || _a === void 0 ? void 0 : _a.value; @@ -4614,7 +4614,7 @@ function findAllVersions(toolName, arch) { return versions; } exports.findAllVersions = findAllVersions; -function getManifestFromRepo(owner, repo, auth, branch = 'master') { +function getManifestFromRepo(owner, repo, auth, branch = 'main') { return __awaiter(this, void 0, void 0, function* () { let releases = []; const treeUrl = `https://api.github.com/repos/${owner}/${repo}/git/trees/${branch}`; @@ -14139,7 +14139,7 @@ function getApps(argocd) { core.error(`Error when running command: ${command}`); core.error(e); } - return apps.filter(app => app.spec.source.targetRevision === 'master' || app.spec.source.targetRevision === 'main'); + return apps.filter(app => app.spec.source.targetRevision === 'main' || app.spec.source.targetRevision === 'main'); }); } function postDiffComment(diffs) { @@ -14149,8 +14149,8 @@ function postDiffComment(diffs) { const sha = (_b = (_a = github.context.payload.pull_request) === null || _a === void 0 ? void 0 : _a.head) === null || _b === void 0 ? void 0 : _b.sha; const commitLink = `https://github.com/${owner}/${repo}/pull/${github.context.issue.number}/commits/${sha}`; const shortCommitSha = String(sha).substr(0, 7); - const diffOutput = diffs.map(({ app, diff, error }) => ` -App: [\`${app.metadata.name}\`](https://${ARGOCD_SERVER_URL}/applications/${app.metadata.name}) + const diffOutput = diffs.map(({ app, diff, error }) => ` +App: [\`${app.metadata.name}\`](https://${ARGOCD_SERVER_URL}/applications/${app.metadata.name}) YAML generation: ${error ? ' Error 🛑' : 'Success 🟢'} App sync status: ${app.status.sync.status === 'Synced' ? 'Synced ✅' : 'Out of Sync ⚠️ '} ${error @@ -14229,7 +14229,7 @@ function run() { const argocd = yield setupArgoCDCommand(); const apps = yield getApps(argocd); if (apps.length === 0) { - core.setFailed(`No apps found for repo: ${github.context.repo.owner}/${github.context.repo.repo} with target revision "master" or "main"`); + core.setFailed(`No apps found for repo: ${github.context.repo.owner}/${github.context.repo.repo} with target revision "main" or "main"`); return; } core.info(`Found apps: ${apps.map(a => a.metadata.name).join(', ')}`); @@ -14435,7 +14435,7 @@ module.exports = JSON.parse('[[[0,44],"disallowed_STD3_valid"],[[45,46],"valid"] /************************************************************************/ /******/ // The module cache /******/ var __webpack_module_cache__ = {}; -/******/ +/******/ /******/ // The require function /******/ function __nccwpck_require__(moduleId) { /******/ // Check if module is in cache @@ -14449,7 +14449,7 @@ module.exports = JSON.parse('[[[0,44],"disallowed_STD3_valid"],[[45,46],"valid"] /******/ // no module.loaded needed /******/ exports: {} /******/ }; -/******/ +/******/ /******/ // Execute the module function /******/ var threw = true; /******/ try { @@ -14458,23 +14458,23 @@ module.exports = JSON.parse('[[[0,44],"disallowed_STD3_valid"],[[45,46],"valid"] /******/ } finally { /******/ if(threw) delete __webpack_module_cache__[moduleId]; /******/ } -/******/ +/******/ /******/ // Return the exports of the module /******/ return module.exports; /******/ } -/******/ +/******/ /************************************************************************/ /******/ /* webpack/runtime/compat */ -/******/ +/******/ /******/ if (typeof __nccwpck_require__ !== 'undefined') __nccwpck_require__.ab = __dirname + "/"; -/******/ +/******/ /************************************************************************/ -/******/ +/******/ /******/ // startup /******/ // Load entry module and return exports /******/ // This entry module is referenced by other modules so it can't be inlined /******/ var __webpack_exports__ = __nccwpck_require__(399); /******/ module.exports = __webpack_exports__; -/******/ +/******/ /******/ })() -; \ No newline at end of file +; diff --git a/src/main.ts b/src/main.ts index 7843c99..b27e2cf 100644 --- a/src/main.ts +++ b/src/main.ts @@ -96,7 +96,7 @@ async function getApps(argocd: (params: string) => Promise): Promise core.error(e); } return apps.filter( - app => app.spec.source.targetRevision === 'master' || app.spec.source.targetRevision === 'main' + app => app.spec.source.targetRevision === 'main' ); } @@ -113,8 +113,8 @@ async function postDiffComment(diffs: Diff[]): Promise { const shortCommitSha = String(sha).substr(0, 7); const diffOutput = diffs.map( - ({ app, diff, error }) => ` -App: [\`${app.metadata.name}\`](https://${ARGOCD_SERVER_URL}/applications/${app.metadata.name}) + ({ app, diff, error }) => ` +App: [\`${app.metadata.name}\`](https://${ARGOCD_SERVER_URL}/applications/${app.metadata.name}) YAML generation: ${error ? ' Error 🛑' : 'Success 🟢'} App sync status: ${app.status.sync.status === 'Synced' ? 'Synced ✅' : 'Out of Sync ⚠️ '} ${ @@ -205,7 +205,7 @@ async function run(): Promise { const apps = await getApps(argocd); if (apps.length === 0) { core.setFailed( - `No apps found for repo: ${github.context.repo.owner}/${github.context.repo.repo} with target revision "master" or "main"` + `No apps found for repo: ${github.context.repo.owner}/${github.context.repo.repo} with target revision "main"` ); return; }