Skip to content

Conversation

trim21
Copy link
Contributor

@trim21 trim21 commented Nov 13, 2024

No description provided.

@crazy-max
Copy link
Member

#470 has been merged, can you rebase please?

@trim21
Copy link
Contributor Author

trim21 commented Nov 13, 2024

I find a problem, we add Git.commitDate as async function but everything in Meta is synchronously...

Copy link
Member

@crazy-max crazy-max left a comment

Choose a reason for hiding this comment

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

@trim21 trim21 marked this pull request as ready for review November 13, 2024 14:13
@trim21 trim21 changed the title add variable commit_date feat: add variable commit_date Nov 13, 2024
@trim21
Copy link
Contributor Author

trim21 commented Nov 13, 2024

it will use local event data file for push event, and fallback to github api for PR.

@trim21

This comment was marked as outdated.

@trim21
Copy link
Contributor Author

trim21 commented Nov 13, 2024

I may need to update GitHub mocking logic for better code style

@trim21
Copy link
Contributor Author

trim21 commented Nov 13, 2024

done

@trim21
Copy link
Contributor Author

trim21 commented Nov 14, 2024

review applied

@trim21
Copy link
Contributor Author

trim21 commented Nov 14, 2024

forget to run eslint 😅

@crazy-max
Copy link
Member

crazy-max commented Nov 14, 2024

Can you add

core.info(`commitDate: ${context.commitDate}`);

to:

await core.group(`Context info`, async () => {

@trim21
Copy link
Contributor Author

trim21 commented Nov 14, 2024

done

Copy link
Member

@crazy-max crazy-max left a comment

Choose a reason for hiding this comment

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

I just merged #472 to check the behavior for git context, can you rebase?

Comment on lines +122 to +126
const commit = await toolkit.github.octokit.request('GET /repos/{owner}/{repo}/commits/{commit_sha}', {
commit_sha: sha,
owner: GitHub.context.repo.owner,
repo: GitHub.context.repo.repo
});
Copy link
Member

Choose a reason for hiding this comment

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

I don't think this would work for pull requests from a fork

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Member

@crazy-max crazy-max Nov 14, 2024

Choose a reason for hiding this comment

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

Looking at https://docs.github.com/en/rest/commits/commits?apiVersion=2022-11-28#get-a-commit--parameters I think we can just pass the full ref like:

Suggested change
const commit = await toolkit.github.octokit.request('GET /repos/{owner}/{repo}/commits/{commit_sha}', {
commit_sha: sha,
owner: GitHub.context.repo.owner,
repo: GitHub.context.repo.repo
});
const commit = await toolkit.github.octokit.request('GET /repos/{owner}/{repo}/commits/{GitHub.context.ref}', {
owner: GitHub.context.repo.owner,
repo: GitHub.context.repo.repo
});

In case of a pull request it would be smth like 'GET /repos/{owner}/{repo}/commits/pull/471/merge' for your pr.

Copy link
Contributor Author

@trim21 trim21 Nov 14, 2024

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

see this: trim21#2

I meant for a pull request from a fork but seems GitHub handles that: https://github.com/docker/metadata-action/actions/runs/11832905758/job/32970605385?pr=471#step:3:18

Copy link
Contributor Author

Choose a reason for hiding this comment

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

in anyway, if sha is correct, we will get a commit. even if we send request to head repo not base repo

Copy link
Member

@crazy-max crazy-max left a comment

Choose a reason for hiding this comment

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

Overall LGTM thanks!

Can we have more test cases in meta.test.ts to cover other kind of events:

Signed-off-by: Trim21 <trim21.me@gmail.com>
@trim21
Copy link
Contributor Author

trim21 commented Nov 16, 2024

done

Copy link
Member

@crazy-max crazy-max left a comment

Choose a reason for hiding this comment

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

LGTM thanks!

@crazy-max crazy-max merged commit c85c22a into docker:master Nov 18, 2024
35 checks passed
@trim21
Copy link
Contributor Author

trim21 commented Nov 18, 2024

is there a release cycle?

@crazy-max
Copy link
Member

is there a release cycle?

Yes probably this week

@trim21
Copy link
Contributor Author

trim21 commented Nov 18, 2024

I forget to add this to toc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants