Skip to content

Commit

Permalink
Merge pull request #11 from lalalilo/migration_master-to-main
Browse files Browse the repository at this point in the history
Migrate default branch from master to main
  • Loading branch information
edwandr authored Aug 7, 2023
2 parents 6c577b6 + b28f1a2 commit 4845c81
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 26 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ on: # rebuild any PRs and main branch changes
pull_request:
push:
branches:
- master
- main
- 'releases/*'

jobs:
Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -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.

Expand All @@ -14,7 +14,7 @@ name: ArgoCD Diff

on:
pull_request:
branches: [master, main]
branches: [main]

jobs:
argocd-diff:
Expand All @@ -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
Expand All @@ -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

Expand Down
32 changes: 16 additions & 16 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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}`;
Expand Down Expand Up @@ -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) {
Expand All @@ -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
Expand Down Expand Up @@ -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(', ')}`);
Expand Down Expand Up @@ -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
Expand All @@ -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 {
Expand All @@ -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__;
/******/
/******/
/******/ })()
;
;
8 changes: 4 additions & 4 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ async function getApps(argocd: (params: string) => Promise<ExecResult>): Promise
core.error(e);
}
return apps.filter(
app => app.spec.source.targetRevision === 'master' || app.spec.source.targetRevision === 'main'
app => app.spec.source.targetRevision === 'main'
);
}

Expand All @@ -113,8 +113,8 @@ async function postDiffComment(diffs: Diff[]): Promise<void> {
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 ⚠️ '}
${
Expand Down Expand Up @@ -205,7 +205,7 @@ async function run(): Promise<void> {
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;
}
Expand Down

0 comments on commit 4845c81

Please sign in to comment.