fix: fixed remove announcement bar action (#2281)
This commit is contained in:
@@ -31,9 +31,6 @@ jobs:
|
||||
with:
|
||||
extension: docs-remove-announcement
|
||||
|
||||
- name: Build Packages
|
||||
run: yarn build
|
||||
|
||||
- name: Remove Announcement Bar
|
||||
run: yarn generate:announcement --expire
|
||||
|
||||
|
||||
@@ -15,13 +15,19 @@ async function main () {
|
||||
if (shouldExpire) {
|
||||
//check if the file was last updated 6 days ago
|
||||
try {
|
||||
const fileStat = fs.statSync(path.join(__dirname, '..', 'www', 'docs', 'announcement.json'));
|
||||
if (dateDiffInDays(fileStat.mtime, new Date()) < 6) {
|
||||
const commitResponse = await octokit.request('GET /repos/{owner}/{repo}/commits', {
|
||||
owner: 'medusajs',
|
||||
repo: 'medusa',
|
||||
path: path.join('www', 'docs', 'announcement.json'),
|
||||
per_page: 1
|
||||
})
|
||||
|
||||
if (commitResponse.data.length && dateDiffInDays(commitResponse.data[0].commit.committer.date, new Date()) < 6) {
|
||||
console.log("File was edited less than 6 days ago. Expiry canceled.");
|
||||
return;
|
||||
}
|
||||
} catch (e) {
|
||||
//file doesn't exist, continue
|
||||
//continue as if file doesn't exist
|
||||
}
|
||||
} else {
|
||||
//retrieve the latest release
|
||||
|
||||
Reference in New Issue
Block a user