From 9871aedc12ddb9b50783701656feb07dc8b84951 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mert=20Can=20Alt=C4=B1n?= Date: Wed, 7 Dec 2022 15:01:24 +0300 Subject: [PATCH 1/5] actionjs refactor --- src/action.js | 74 +++++++++++++++++++++++++-------------------------- 1 file changed, 37 insertions(+), 37 deletions(-) diff --git a/src/action.js b/src/action.js index c8efcbe..18a393e 100644 --- a/src/action.js +++ b/src/action.js @@ -4,73 +4,73 @@ const core = require('@actions/core'); const github = require('@actions/github'); async function run() { - const GITHUB_TOKEN = core.getInput('GITHUB_TOKEN'); - const CSW_URL = core.getInput('CSW_URL'); - const IMAGE_NAME = core.getInput('IMAGE_NAME'); - const CSW_APP_ID = core.getInput('CSW_APP_ID'); - const REGISTRY_URL = core.getInput('REGISTRY_URL'); - const REGISTRY_USER = core.getInput('REGISTRY_USER'); - const REGISTRY_PASSWORD = core.getInput('REGISTRY_PASSWORD'); - const CREATE_SUCCESS_ISSUE = core.getInput('CREATE_SUCCESS_ISSUE'); - const CREATE_FAILURE_ISSUE = core.getInput('CREATE_FAILURE_ISSUE'); + // Get inputs from GitHub action + const inputs = [ + 'GITHUB_TOKEN', + 'CSW_URL', + 'IMAGE_NAME', + 'CSW_APP_ID', + 'REGISTRY_URL', + 'REGISTRY_USER', + 'REGISTRY_PASSWORD', + 'CREATE_SUCCESS_ISSUE', + 'CREATE_FAILURE_ISSUE' + ]; + const values = inputs.map(input => core.getInput(input)); - if (typeof GITHUB_TOKEN !== 'string') { - throw new Error('Invalid GITHUB_TOKEN: did you forget to set it in your action config?'); - } - - if (typeof CSW_URL !== 'string') { - throw new Error('Invalid CSW_URL: did you forget to set it in your action config?'); - } - - if (typeof CSW_APP_ID !== 'string') { - throw new Error('Invalid CSW_APP_ID: did you forget to set it in your action config?'); + // Validate inputs + const validateInput = (name, value) => { + if (typeof value !== 'string') { + throw new Error(`Invalid ${name}: did you forget to set it in your action config?`); + } } - if (typeof IMAGE_NAME !== 'string') { - throw new Error('Invalid IMAGE_NAME: did you forget to set it in your action config?'); - } + inputs.forEach((input, index) => validateInput(input, values[index])); + // Deploy app using inputs provided by GitHub action const context = github.context; - const octokit = github.getOctokit(GITHUB_TOKEN) + const octokit = github.getOctokit(GITHUB_TOKEN); + // Send request to deploy app const response = await axios.post(`${CSW_URL}/api/v1/apps/deploy`, { "image": `${IMAGE_NAME}`, "app_id": CSW_APP_ID, "registry": REGISTRY_URL, "registry_user": REGISTRY_USER, "registry_pass": REGISTRY_PASSWORD - }) + }); - if (response.status !== 200) { - if (CREATE_FAILURE_ISSUE === 'true') { + // Check response status and create issue if needed + if (response.status === 200) { + if (CREATE_SUCCESS_ISSUE === 'true') { await octokit.issues.create({ ...context.repo, - title: 'Deployment failed', - body: `Deployment failed for ${IMAGE_NAME}`, + title: 'Deployment successful', + body: `Deployment successful for ${IMAGE_NAME}`, labels: ['deployment', { - name: 'deployment-failed', - color: '#B60205' + name: 'deployment-success', + color: '#0E8A16' } ] }); } - core.setFailed(`Deployment failed: please check the logs for more information`); + core.setOutput('deployment', "App deployed successfully"); } else { - if (CREATE_SUCCESS_ISSUE === 'true') { + if (CREATE_FAILURE_ISSUE === 'true') { await octokit.issues.create({ ...context.repo, - title: 'Deployment successful', - body: `Deployment successful for ${IMAGE_NAME}`, + title: 'Deployment failed', + body: `Deployment failed for ${IMAGE_NAME}`, labels: ['deployment', { - name: 'deployment-success', - color: '#0E8A16' + name: 'deployment-failed', + color: '#B60205' } ] }); } - core.setOutput('deployment', "App deployed successfully"); + core.setFailed(`Deployment failed: please check the logs for more information`); } } From 9a098ecc7679ad1b30ddb4108d0131ae8fb4d844 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 11 Nov 2023 04:09:05 +0000 Subject: [PATCH 2/5] Bump axios from 0.27.2 to 1.6.0 Bumps [axios](https://github.com/axios/axios) from 0.27.2 to 1.6.0. - [Release notes](https://github.com/axios/axios/releases) - [Changelog](https://github.com/axios/axios/blob/v1.x/CHANGELOG.md) - [Commits](https://github.com/axios/axios/compare/v0.27.2...v1.6.0) --- updated-dependencies: - dependency-name: axios dependency-type: direct:development ... Signed-off-by: dependabot[bot] --- package.json | 2 +- yarn.lock | 24 +++++++++++++++--------- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/package.json b/package.json index 00a1b60..5b5c695 100644 --- a/package.json +++ b/package.json @@ -21,7 +21,7 @@ "@actions/core": "^1.9.1", "@actions/github": "^4.0.0", "@vercel/ncc": "^0.27.0", - "axios": "^0.27.2", + "axios": "^1.6.0", "dotenv": "^8.2.0" } } diff --git a/yarn.lock b/yarn.lock index 9c0144d..becec70 100644 --- a/yarn.lock +++ b/yarn.lock @@ -171,13 +171,14 @@ asynckit@^0.4.0: resolved "https://registry.yarnpkg.com/asynckit/-/asynckit-0.4.0.tgz#c79ed97f7f34cb8f2ba1bc9790bcc366474b4b79" integrity sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q== -axios@^0.27.2: - version "0.27.2" - resolved "https://registry.yarnpkg.com/axios/-/axios-0.27.2.tgz#207658cc8621606e586c85db4b41a750e756d972" - integrity sha512-t+yRIyySRTp/wua5xEr+z1q60QmLq8ABsS5O9Me1AsE5dfKqgnCFzwiCZZ/cGNd1lq4/7akDWMxdhVlucjmnOQ== +axios@^1.6.0: + version "1.6.0" + resolved "https://registry.yarnpkg.com/axios/-/axios-1.6.0.tgz#f1e5292f26b2fd5c2e66876adc5b06cdbd7d2102" + integrity sha512-EZ1DYihju9pwVB+jg67ogm+Tmqc6JmhamRN6I4Zt8DfZu5lbcQGw3ozH9lFejSJgs/ibaef3A9PMXPLeefFGJg== dependencies: - follow-redirects "^1.14.9" + follow-redirects "^1.15.0" form-data "^4.0.0" + proxy-from-env "^1.1.0" before-after-hook@^2.2.0: version "2.2.2" @@ -206,10 +207,10 @@ dotenv@^8.2.0: resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-8.2.0.tgz#97e619259ada750eea3e4ea3e26bceea5424b16a" integrity sha512-8sJ78ElpbDJBHNeBzUbUVLsqKdccaa/BXF1uPTw3GrvQTBgrQrtObr2mUrE38vzYd8cEv+m/JBfDLioYcfXoaw== -follow-redirects@^1.14.9: - version "1.15.0" - resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.15.0.tgz#06441868281c86d0dda4ad8bdaead2d02dca89d4" - integrity sha512-aExlJShTV4qOUOL7yF1U5tvLCB0xQuudbf6toyYA0E/acBNw71mvjFTnLaRp50aQaYocMR0a/RMMBIHeZnGyjQ== +follow-redirects@^1.15.0: + version "1.15.3" + resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.15.3.tgz#fe2f3ef2690afce7e82ed0b44db08165b207123a" + integrity sha512-1VzOtuEM8pC9SFU1E+8KfTjZyMztRsgEfwQl44z8A25uy13jSzTj6dyK2Df52iV0vgHCfBwLhDWevLn95w5v6Q== form-data@^4.0.0: version "4.0.0" @@ -251,6 +252,11 @@ once@^1.4.0: dependencies: wrappy "1" +proxy-from-env@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/proxy-from-env/-/proxy-from-env-1.1.0.tgz#e102f16ca355424865755d2c9e8ea4f24d58c3e2" + integrity sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg== + tr46@~0.0.3: version "0.0.3" resolved "https://registry.yarnpkg.com/tr46/-/tr46-0.0.3.tgz#8184fd347dac9cdc185992f3a6622e14b9d9ab6a" From 03152a6e432ea02da390fbc5bce73367ba153b7f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 11 Jan 2024 03:59:27 +0000 Subject: [PATCH 3/5] Bump follow-redirects from 1.15.3 to 1.15.4 Bumps [follow-redirects](https://github.com/follow-redirects/follow-redirects) from 1.15.3 to 1.15.4. - [Release notes](https://github.com/follow-redirects/follow-redirects/releases) - [Commits](https://github.com/follow-redirects/follow-redirects/compare/v1.15.3...v1.15.4) --- updated-dependencies: - dependency-name: follow-redirects dependency-type: indirect ... Signed-off-by: dependabot[bot] --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index becec70..4189c17 100644 --- a/yarn.lock +++ b/yarn.lock @@ -208,9 +208,9 @@ dotenv@^8.2.0: integrity sha512-8sJ78ElpbDJBHNeBzUbUVLsqKdccaa/BXF1uPTw3GrvQTBgrQrtObr2mUrE38vzYd8cEv+m/JBfDLioYcfXoaw== follow-redirects@^1.15.0: - version "1.15.3" - resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.15.3.tgz#fe2f3ef2690afce7e82ed0b44db08165b207123a" - integrity sha512-1VzOtuEM8pC9SFU1E+8KfTjZyMztRsgEfwQl44z8A25uy13jSzTj6dyK2Df52iV0vgHCfBwLhDWevLn95w5v6Q== + version "1.15.4" + resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.15.4.tgz#cdc7d308bf6493126b17ea2191ea0ccf3e535adf" + integrity sha512-Cr4D/5wlrb0z9dgERpUL3LrmPKVDsETIJhaCMeDfuFYcqa5bldGV6wBsAN6X/vxlXQtFBMrXdXxdL8CbDTGniw== form-data@^4.0.0: version "4.0.0" From 3ef6a24ddea1f5327e4fd412aa047c89d50d46ce Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 16 Mar 2024 22:59:21 +0000 Subject: [PATCH 4/5] Bump follow-redirects from 1.15.4 to 1.15.6 Bumps [follow-redirects](https://github.com/follow-redirects/follow-redirects) from 1.15.4 to 1.15.6. - [Release notes](https://github.com/follow-redirects/follow-redirects/releases) - [Commits](https://github.com/follow-redirects/follow-redirects/compare/v1.15.4...v1.15.6) --- updated-dependencies: - dependency-name: follow-redirects dependency-type: indirect ... Signed-off-by: dependabot[bot] --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index 4189c17..9956413 100644 --- a/yarn.lock +++ b/yarn.lock @@ -208,9 +208,9 @@ dotenv@^8.2.0: integrity sha512-8sJ78ElpbDJBHNeBzUbUVLsqKdccaa/BXF1uPTw3GrvQTBgrQrtObr2mUrE38vzYd8cEv+m/JBfDLioYcfXoaw== follow-redirects@^1.15.0: - version "1.15.4" - resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.15.4.tgz#cdc7d308bf6493126b17ea2191ea0ccf3e535adf" - integrity sha512-Cr4D/5wlrb0z9dgERpUL3LrmPKVDsETIJhaCMeDfuFYcqa5bldGV6wBsAN6X/vxlXQtFBMrXdXxdL8CbDTGniw== + version "1.15.6" + resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.15.6.tgz#7f815c0cda4249c74ff09e95ef97c23b5fd0399b" + integrity sha512-wWN62YITEaOpSK584EZXJafH1AGpO8RVgElfkuXbTOrPX4fIfOyEpW/CsiNd8JdYrAoOvafRTOEnvsO++qCqFA== form-data@^4.0.0: version "4.0.0" From d9d6fdf751a43065449f68887da864cfa22ac2e6 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 8 Mar 2025 18:32:02 +0000 Subject: [PATCH 5/5] Bump axios from 1.6.0 to 1.8.2 Bumps [axios](https://github.com/axios/axios) from 1.6.0 to 1.8.2. - [Release notes](https://github.com/axios/axios/releases) - [Changelog](https://github.com/axios/axios/blob/v1.x/CHANGELOG.md) - [Commits](https://github.com/axios/axios/compare/v1.6.0...v1.8.2) --- updated-dependencies: - dependency-name: axios dependency-type: direct:development ... Signed-off-by: dependabot[bot] --- package.json | 2 +- yarn.lock | 18 +++++++++--------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/package.json b/package.json index 5b5c695..122fd5a 100644 --- a/package.json +++ b/package.json @@ -21,7 +21,7 @@ "@actions/core": "^1.9.1", "@actions/github": "^4.0.0", "@vercel/ncc": "^0.27.0", - "axios": "^1.6.0", + "axios": "^1.8.2", "dotenv": "^8.2.0" } } diff --git a/yarn.lock b/yarn.lock index 9956413..9ad8b95 100644 --- a/yarn.lock +++ b/yarn.lock @@ -171,12 +171,12 @@ asynckit@^0.4.0: resolved "https://registry.yarnpkg.com/asynckit/-/asynckit-0.4.0.tgz#c79ed97f7f34cb8f2ba1bc9790bcc366474b4b79" integrity sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q== -axios@^1.6.0: - version "1.6.0" - resolved "https://registry.yarnpkg.com/axios/-/axios-1.6.0.tgz#f1e5292f26b2fd5c2e66876adc5b06cdbd7d2102" - integrity sha512-EZ1DYihju9pwVB+jg67ogm+Tmqc6JmhamRN6I4Zt8DfZu5lbcQGw3ozH9lFejSJgs/ibaef3A9PMXPLeefFGJg== +axios@^1.8.2: + version "1.8.2" + resolved "https://registry.yarnpkg.com/axios/-/axios-1.8.2.tgz#fabe06e241dfe83071d4edfbcaa7b1c3a40f7979" + integrity sha512-ls4GYBm5aig9vWx8AWDSGLpnpDQRtWAfrjU+EuytuODrFBkqesN2RkOQCBzrA1RQNHw1SmRMSDDDSwzNAYQ6Rg== dependencies: - follow-redirects "^1.15.0" + follow-redirects "^1.15.6" form-data "^4.0.0" proxy-from-env "^1.1.0" @@ -207,10 +207,10 @@ dotenv@^8.2.0: resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-8.2.0.tgz#97e619259ada750eea3e4ea3e26bceea5424b16a" integrity sha512-8sJ78ElpbDJBHNeBzUbUVLsqKdccaa/BXF1uPTw3GrvQTBgrQrtObr2mUrE38vzYd8cEv+m/JBfDLioYcfXoaw== -follow-redirects@^1.15.0: - version "1.15.6" - resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.15.6.tgz#7f815c0cda4249c74ff09e95ef97c23b5fd0399b" - integrity sha512-wWN62YITEaOpSK584EZXJafH1AGpO8RVgElfkuXbTOrPX4fIfOyEpW/CsiNd8JdYrAoOvafRTOEnvsO++qCqFA== +follow-redirects@^1.15.6: + version "1.15.9" + resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.15.9.tgz#a604fa10e443bf98ca94228d9eebcc2e8a2c8ee1" + integrity sha512-gew4GsXizNgdoRyqmyfMHyAmXsZDk6mHkSxZFCzW9gwlbtOW44CDtYavM+y+72qD/Vq2l550kMF52DT8fOLJqQ== form-data@^4.0.0: version "4.0.0"