diff --git a/dist/index.js b/dist/index.js index 4c90116..c63af68 100644 --- a/dist/index.js +++ b/dist/index.js @@ -15666,9 +15666,20 @@ async function run() { const currentVersionURL = `https://raw.githubusercontent.com/${github.context.repo.owner}/${github.context.repo.repo}/${baseSHA}${workingDirectory}version`; core.info(`current version url: ${currentVersionURL}`); - let { data: currentVersion } = await axios.get(currentVersionURL, { - headers, - }); + let { data: currentVersion } = await axios + .get(currentVersionURL, { + headers, + }) + .catch((error) => { + // if status code 404, old version file is not exist, setup version to 0.0.0 + if (error.response && error.response.status === 404) { + return { + data: '0.0.0', + }; + } + throw error; + }); + currentVersion = currentVersion.toString().trim(); const nextVersionURL = `https://raw.githubusercontent.com/${github.context.repo.owner}/${github.context.repo.repo}/${headSHA}${workingDirectory}version`; diff --git a/package.json b/package.json index ae6fd8a..ecf4cf8 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "action-version-check", - "version": "0.0.3", + "version": "0.0.4", "description": "Check if the current version is compliant with the specification", "main": "index.js", "scripts": { diff --git a/src/index.js b/src/index.js index 0ecf210..26f0e45 100644 --- a/src/index.js +++ b/src/index.js @@ -69,9 +69,20 @@ async function run() { const currentVersionURL = `https://raw.githubusercontent.com/${github.context.repo.owner}/${github.context.repo.repo}/${baseSHA}${workingDirectory}version`; core.info(`current version url: ${currentVersionURL}`); - let { data: currentVersion } = await axios.get(currentVersionURL, { - headers, - }); + let { data: currentVersion } = await axios + .get(currentVersionURL, { + headers, + }) + .catch((error) => { + // if status code 404, old version file is not exist, setup version to 0.0.0 + if (error.response && error.response.status === 404) { + return { + data: '0.0.0', + }; + } + throw error; + }); + currentVersion = currentVersion.toString().trim(); const nextVersionURL = `https://raw.githubusercontent.com/${github.context.repo.owner}/${github.context.repo.repo}/${headSHA}${workingDirectory}version`;