fix: fixed remove announcement bar action (#2281)

This commit is contained in:
Shahed Nasser authored and GitHub committed 2022-09-30 13:06:56 +03:00
1 parent 7a721e6447
commit 64ebece3b4
2 files changed
+9 -6

No files matched your search

@@ -31,9 +31,6 @@ jobs:
with: with:
extension: docs-remove-announcement extension: docs-remove-announcement
- name: Build Packages
run: yarn build
- name: Remove Announcement Bar - name: Remove Announcement Bar
run: yarn generate:announcement --expire run: yarn generate:announcement --expire
+9 -3
View File
@@ -15,13 +15,19 @@ async function main () {
if (shouldExpire) { if (shouldExpire) {
//check if the file was last updated 6 days ago //check if the file was last updated 6 days ago
try { try {
const fileStat = fs.statSync(path.join(__dirname, '..', 'www', 'docs', 'announcement.json')); const commitResponse = await octokit.request('GET /repos/{owner}/{repo}/commits', {
if (dateDiffInDays(fileStat.mtime, new Date()) < 6) { 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."); console.log("File was edited less than 6 days ago. Expiry canceled.");
return; return;
} }
} catch (e) { } catch (e) {
//file doesn't exist, continue //continue as if file doesn't exist
} }
} else { } else {
//retrieve the latest release //retrieve the latest release