Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bug fix] The timezone has not been configured correctly #732

Merged
merged 2 commits into from
Jan 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions .github/scripts/release_notes/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');

Expand All @@ -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()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you remove these logs?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These logs were utilized for manual testing and validation. For some reason, setting the timezone value in process.env.TZ does not function correctly for CI runners. Just in case the szenius/[email protected] action fails to update the timezone quietly, it's intended to keep these logs for future debugging.

console.log(`Time zone offset is: ${offset}`);
const timezone = Intl.DateTimeFormat().resolvedOptions().timeZone;
console.log(`Time zone is: ${timezone}`);

console.log(`Start to fetch release info from GitHub created after [${convertToDateTime(timestampObj.ts)}]`);

Expand Down
11 changes: 0 additions & 11 deletions .github/scripts/release_notes/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
7 changes: 7 additions & 0 deletions .github/workflows/release-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,13 @@ jobs:

env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Set timezone
uses: szenius/[email protected]
with:
timezoneLinux: "America/Los_Angeles"
timezoneMacos: "America/Los_Angeles"

- name: Yarn install
run: yarn install

Expand Down
Loading