Skip to content

Commit

Permalink
fix: resolve the bug of new package version not exist (#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
FireTable authored Sep 4, 2023
1 parent 31a5327 commit 1e98110
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 7 deletions.
17 changes: 14 additions & 3 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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`;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down
17 changes: 14 additions & 3 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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`;
Expand Down

0 comments on commit 1e98110

Please sign in to comment.