You've already forked dynamic-badges-action
🪲 Fix check of previous content
This commit is contained in:
16
index.js
16
index.js
@@ -26,7 +26,6 @@ async function updateGist(body) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
console.log(await response.text());
|
|
||||||
core.setFailed(
|
core.setFailed(
|
||||||
`Failed to create gist, response status code: ${response.status} ${response.statusText}`
|
`Failed to create gist, response status code: ${response.status} ${response.statusText}`
|
||||||
);
|
);
|
||||||
@@ -169,13 +168,9 @@ try {
|
|||||||
})
|
})
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
// print the error, but don't fail the action.
|
return Promise.reject(
|
||||||
console.log(
|
|
||||||
`Failed to get gist: ${response.status} ${response.statusText}`
|
`Failed to get gist: ${response.status} ${response.statusText}`
|
||||||
);
|
);
|
||||||
response.text().then((text) => console.log(text));
|
|
||||||
|
|
||||||
return {};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return response.json();
|
return response.json();
|
||||||
@@ -183,8 +178,8 @@ try {
|
|||||||
.then((oldGist) => {
|
.then((oldGist) => {
|
||||||
let shouldUpdate = true;
|
let shouldUpdate = true;
|
||||||
|
|
||||||
if (oldGist?.body?.files?.[filename]) {
|
if (oldGist?.files?.[filename]) {
|
||||||
const oldContent = oldGist.body.files[filename].content;
|
const oldContent = oldGist.files[filename].content;
|
||||||
|
|
||||||
if (oldContent === content) {
|
if (oldContent === content) {
|
||||||
console.log(
|
console.log(
|
||||||
@@ -195,7 +190,7 @@ try {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (shouldUpdate) {
|
if (shouldUpdate) {
|
||||||
if (oldGist?.body?.files?.[filename]) {
|
if (oldGist?.files?.[filename]) {
|
||||||
console.log(`Content changed, updating gist at ${filename}.`);
|
console.log(`Content changed, updating gist at ${filename}.`);
|
||||||
} else {
|
} else {
|
||||||
console.log(`Content didn't exist, creating gist at ${filename}.`);
|
console.log(`Content didn't exist, creating gist at ${filename}.`);
|
||||||
@@ -203,6 +198,9 @@ try {
|
|||||||
|
|
||||||
updateGist(body);
|
updateGist(body);
|
||||||
}
|
}
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
core.setFailed(error);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
Reference in New Issue
Block a user