From 7a36f34600a0b536e1763e4bd73fde722cf2c949 Mon Sep 17 00:00:00 2001 From: yansong Date: Mon, 6 Jan 2025 12:40:08 -0600 Subject: [PATCH 1/2] set the timezone to PST before running the release notes scripts --- .github/scripts/release_notes/index.js | 12 ++++++------ .github/scripts/release_notes/utils.js | 11 ----------- .github/workflows/release-pr.yml | 7 +++++++ 3 files changed, 13 insertions(+), 17 deletions(-) diff --git a/.github/scripts/release_notes/index.js b/.github/scripts/release_notes/index.js index 5ee0975f12..31a610b6ab 100644 --- a/.github/scripts/release_notes/index.js +++ b/.github/scripts/release_notes/index.js @@ -12,7 +12,7 @@ governing permissions and limitations under the License. const timestampObj = require('./timestamp.json') const { repoNames, releaseNotesLocation, MAIN_RELEASE_NOTES_LOCATION, PLATFORM_ENUM, EXTENSION_ENUM } = require('./constants') -const { saveJsonObjToFile, setTimeZoneToPST, convertToDateTime } = require('./utils') +const { saveJsonObjToFile, convertToDateTime } = require('./utils') const { updateReleaseNotesPage } = require('./updateReleaseNotes'); const { fetchReleaseInfoFromGitHub, sortReleaseInfoByDateASC } = require('./fetchReleaseNotes'); @@ -25,11 +25,11 @@ if (GITHUB_TOKEN === undefined) { const DRY_RUN = process.argv.includes("--dry-run") -// Before running the script, make sure the default time zone is set to PST in the GitHub action -// TODO: For some reason, the code below to update the timezone of the Github Action runners is not working. Ignore this step for now and will fix it later. -// if (!setTimeZoneToPST()) { -// throw new Error("The default time zone is not set to PST") -// } + +const offset = new Date().getTimezoneOffset() +console.log(`Timezone offset is: ${offset}`); +const timezone = Intl.DateTimeFormat().resolvedOptions().timeZone; +console.log(`Timezone is: ${timezone}`); console.log(`Start to fetch release info from GitHub created after [${convertToDateTime(timestampObj.ts)}]`); diff --git a/.github/scripts/release_notes/utils.js b/.github/scripts/release_notes/utils.js index 50459bf53b..c11c1d4825 100644 --- a/.github/scripts/release_notes/utils.js +++ b/.github/scripts/release_notes/utils.js @@ -86,17 +86,6 @@ function convertISODateToRleaseDateFormat(iso8601DateStr) { return `${monthNames[date.getMonth()]} ${date.getDate()}, ${date.getFullYear()}` } -/** - * Sets the time zone of the NodeJS runtime to PST (Pacific Standard Time). - * - * @returns {boolean} Returns true if the time zone is successfully set to PST, false otherwise. - */ -function setTimeZoneToPST() { - process.env.TZ = PST_TIMEZONE - const offset = new Date().getTimezoneOffset() - return (offset === PST_TIMEZONE_OFFSET) -} - function convertToDateTime(timestamp) { const date = new Date(timestamp); return date.toLocaleString(); diff --git a/.github/workflows/release-pr.yml b/.github/workflows/release-pr.yml index aab79b73a9..cc89933d5d 100644 --- a/.github/workflows/release-pr.yml +++ b/.github/workflows/release-pr.yml @@ -32,6 +32,13 @@ jobs: env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Set timezone + uses: szenius/set-timezone@v2.0 + with: + timezoneLinux: "America/Los_Angeles" + timezoneMacos: "America/Los_Angeles" + - name: Yarn install run: yarn install From 1d6fa251cc06d4a17d91a8d9be666dba5b829736 Mon Sep 17 00:00:00 2001 From: Yansong Yang Date: Mon, 6 Jan 2025 12:42:07 -0600 Subject: [PATCH 2/2] Update index.js --- .github/scripts/release_notes/index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/scripts/release_notes/index.js b/.github/scripts/release_notes/index.js index 31a610b6ab..d55a475322 100644 --- a/.github/scripts/release_notes/index.js +++ b/.github/scripts/release_notes/index.js @@ -27,9 +27,9 @@ const DRY_RUN = process.argv.includes("--dry-run") const offset = new Date().getTimezoneOffset() -console.log(`Timezone offset is: ${offset}`); +console.log(`Time zone offset is: ${offset}`); const timezone = Intl.DateTimeFormat().resolvedOptions().timeZone; -console.log(`Timezone is: ${timezone}`); +console.log(`Time zone is: ${timezone}`); console.log(`Start to fetch release info from GitHub created after [${convertToDateTime(timestampObj.ts)}]`);