Skip to content

feat: add variable commit_date#471

Merged
crazy-max merged 1 commit intodocker:masterfrom
trim21:commit-date
Nov 18, 2024
Merged

feat: add variable commit_date#471
crazy-max merged 1 commit intodocker:masterfrom
trim21:commit-date

Conversation

@trim21
Copy link
Copy Markdown
Contributor

@trim21 trim21 commented Nov 13, 2024

No description provided.

@crazy-max
Copy link
Copy Markdown
Member

#470 has been merged, can you rebase please?

@trim21
Copy link
Copy Markdown
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
Copy Markdown
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.

Comment thread src/meta.ts Outdated
Comment thread src/meta.ts Outdated
Comment thread src/meta.ts Outdated
Comment thread src/meta.ts Outdated
@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
Copy Markdown
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
Copy Markdown
Contributor Author

trim21 commented Nov 13, 2024

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

@trim21
Copy link
Copy Markdown
Contributor Author

trim21 commented Nov 13, 2024

done

@trim21
Copy link
Copy Markdown
Contributor Author

trim21 commented Nov 14, 2024

review applied

Comment thread src/context.ts Outdated
Comment thread src/context.ts
@trim21
Copy link
Copy Markdown
Contributor Author

trim21 commented Nov 14, 2024

forget to run eslint 😅

@crazy-max
Copy link
Copy Markdown
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
Copy Markdown
Contributor Author

trim21 commented Nov 14, 2024

done

Copy link
Copy Markdown
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 thread src/meta.ts
Comment thread src/context.ts
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
Copy Markdown
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
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Member

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
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
Copy Markdown
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:

Comment thread __tests__/context.test.ts
Comment thread __tests__/context.test.ts
@trim21
Copy link
Copy Markdown
Contributor Author

trim21 commented Nov 16, 2024

done

Copy link
Copy Markdown
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
@trim21
Copy link
Copy Markdown
Contributor Author

trim21 commented Nov 18, 2024

is there a release cycle?

@crazy-max
Copy link
Copy Markdown
Member

is there a release cycle?

Yes probably this week

@trim21
Copy link
Copy Markdown
Contributor Author

trim21 commented Nov 18, 2024

I forget to add this to toc

renovate Bot added a commit to sdwilsh/sOS that referenced this pull request Apr 29, 2026
##### [\`v6\`](docker/metadata-action@v5...v6)


---
##### [\`v6.0.0\`](https://github.com/docker/metadata-action/releases/tag/v6.0.0)

- Node 24 as default runtime (requires [Actions Runner v2.327.1](https://github.com/actions/runner/releases/tag/v2.327.1) or later) by [@crazy-max](https://github.com/crazy-max) in [#605](docker/metadata-action#605)
- List inputs now preserve `#` inside values while still supporting full-line `#` comments by [@crazy-max](https://github.com/crazy-max) in [#607](docker/metadata-action#607)
- Switch to ESM and update config/test wiring by [@crazy-max](https://github.com/crazy-max) in [#602](docker/metadata-action#602)
- Bump lodash from 4.17.21 to 4.17.23 in [#588](docker/metadata-action#588)
- Bump [@actions/core](https://github.com/actions/core) from 1.11.1 to 3.0.0 in [#599](docker/metadata-action#599)
- Bump [@actions/github](https://github.com/actions/github) from 6.0.1 to 9.0.0 in [#597](docker/metadata-action#597)
- Bump [@docker/actions-toolkit](https://github.com/docker/actions-toolkit) from 0.68.0 to 0.79.0 in [#604](docker/metadata-action#604)
- Bump [@isaacs/brace-expansion](https://github.com/isaacs/brace-expansion) from 5.0.0 to 5.0.1 in [#600](docker/metadata-action#600)
- Bump semver from 7.7.3 to 7.7.4 in [#603](docker/metadata-action#603)

**Full Changelog**: <docker/metadata-action@v5.10.0...v6.0.0>

---
##### [\`v5.10.0\`](https://github.com/docker/metadata-action/releases/tag/v5.10.0)

- Bump [@docker/actions-toolkit](https://github.com/docker/actions-toolkit) from 0.66.0 to 0.68.0 in [#559](docker/metadata-action#559) [#569](docker/metadata-action#569)
- Bump js-yaml from 3.14.1 to 3.14.2 in [#564](docker/metadata-action#564)

**Full Changelog**: <docker/metadata-action@v5.9.0...v5.10.0>

---
##### [\`v5.9.0\`](https://github.com/docker/metadata-action/releases/tag/v5.9.0)

- Add `tag-names` output to return tag names without image base name by [@crazy-max](https://github.com/crazy-max) in [#553](docker/metadata-action#553)
- Bump [@babel/runtime-corejs3](https://github.com/babel/runtime-corejs3) from 7.14.7 to 7.28.2 in [#539](docker/metadata-action#539)
- Bump [@docker/actions-toolkit](https://github.com/docker/actions-toolkit) from 0.62.1 to 0.66.0 in [#555](docker/metadata-action#555)
- Bump brace-expansion from 1.1.11 to 1.1.12 in [#540](docker/metadata-action#540)
- Bump csv-parse from 5.6.0 to 6.1.0 in [#532](docker/metadata-action#532)
- Bump semver from 7.7.2 to 7.7.3 in in [#554](docker/metadata-action#554)
- Bump tmp from 0.2.3 to 0.2.5 in [#541](docker/metadata-action#541)

**Full Changelog**: <docker/metadata-action@v5.8.0...v5.9.0>

---
##### [\`v5.8.0\`](https://github.com/docker/metadata-action/releases/tag/v5.8.0)

- New `is_not_default_branch` global expression by [@crazy-max](https://github.com/crazy-max) in [#535](docker/metadata-action#535)
- Allow to match part of the git tag or value for semver/pep440 types by [@crazy-max](https://github.com/crazy-max) in [#536](docker/metadata-action#536) [#537](docker/metadata-action#537)
- Bump [@actions/github](https://github.com/actions/github) from 6.0.0 to 6.0.1 in [#523](docker/metadata-action#523)
- Bump [@docker/actions-toolkit](https://github.com/docker/actions-toolkit) from 0.56.0 to 0.62.1 in [#526](docker/metadata-action#526)
- Bump form-data from 2.5.1 to 2.5.5 in [#533](docker/metadata-action#533)
- Bump moment-timezone from 0.5.47 to 0.6.0 in [#525](docker/metadata-action#525)
- Bump semver from 7.7.1 to 7.7.2 in [#524](docker/metadata-action#524)

**Full Changelog**: <docker/metadata-action@v5.7.0...v5.8.0>

---
##### [\`v5.7.0\`](https://github.com/docker/metadata-action/releases/tag/v5.7.0)

- Global expressions support for labels and annotations by [@crazy-max](https://github.com/crazy-max) in [#489](docker/metadata-action#489)
- Support disabling outputs as environment variables by [@omus](https://github.com/omus) in [#497](docker/metadata-action#497)
- Bump [@docker/actions-toolkit](https://github.com/docker/actions-toolkit) from 0.44.0 to 0.56.0 in [#507](docker/metadata-action#507) [#509](docker/metadata-action#509)
- Bump csv-parse from 5.5.6 to 5.6.0 in [#482](docker/metadata-action#482)
- Bump moment-timezone from 0.5.46 to 0.5.47 in [#501](docker/metadata-action#501)
- Bump semver from 7.6.3 to 7.7.1 in [#504](docker/metadata-action#504)

**Full Changelog**: <docker/metadata-action@v5.6.1...v5.7.0>

---
##### [\`v5.6.1\`](https://github.com/docker/metadata-action/releases/tag/v5.6.1)

- Fix GitHub API request fallback for commit date by [@crazy-max](https://github.com/crazy-max) in [#478](docker/metadata-action#478)
- Revert to default commit SHA length of 7 by [@crazy-max](https://github.com/crazy-max) in [#480](docker/metadata-action#480)

**Full Changelog**: <docker/metadata-action@v5.6.0...v5.6.1>

---
##### [\`v5.6.0\`](https://github.com/docker/metadata-action/releases/tag/v5.6.0)

- Add `commit_date` global expression by [@trim21](https://github.com/trim21) in [#471](docker/metadata-action#471) [#475](docker/metadata-action#475)
- Increase short commit sha length to 12 for uniqueness by [@crazy-max](https://github.com/crazy-max) in [#467](docker/metadata-action#467)
- Bump [@actions/core](https://github.com/actions/core) from 1.10.1 to 1.11.1 [#460](docker/metadata-action#460)
- Bump [@docker/actions-toolkit](https://github.com/docker/actions-toolkit) from 0.16.1 to 0.44.0 [#391](docker/metadata-action#391) [#399](docker/metadata-action#399) [#413](docker/metadata-action#413) [#441](docker/metadata-action#441)
- Bump braces from 3.0.2 to 3.0.3 [#424](docker/metadata-action#424)
- Bump cross-spawn from 7.0.3 to 7.0.5 [#474](docker/metadata-action#474)
- Bump csv-parse from 5.5.5 to 5.5.6 [#412](docker/metadata-action#412)
- Bump moment-timezone from 0.5.44 to 0.5.46 [#383](docker/metadata-action#383) [#470](docker/metadata-action#470) [#459](docker/metadata-action#459)
- Bump path-to-regexp from 6.2.2 to 6.3.0 [#454](docker/metadata-action#454)
- Bump semver from 7.6.0 to 7.6.3 [#400](docker/metadata-action#400) [#411](docker/metadata-action#411) [#440](docker/metadata-action#440)
- Bump undici from 5.26.3 to 5.28.4 [#386](docker/metadata-action#386) [#402](docker/metadata-action#402)

**Full Changelog**: <docker/metadata-action@v5.5.1...v5.6.0>

---
##### [\`v5.5.1\`](https://github.com/docker/metadata-action/releases/tag/v5.5.1)

- Don't set `cwd://` prefix for local bake files by [@crazy-max](https://github.com/crazy-max) in [#382](docker/metadata-action#382)

**Full Changelog**: <docker/metadata-action@v5.5.0...v5.5.1>

---
##### [\`v5.5.0\`](https://github.com/docker/metadata-action/releases/tag/v5.5.0)

- Set `cwd://` prefix for bake files path by [@crazy-max](https://github.com/crazy-max) in [#370](docker/metadata-action#370)
- Bump [@docker/actions-toolkit](https://github.com/docker/actions-toolkit) from 0.16.0 to 0.16.1 in [#371](docker/metadata-action#371)
- Bump moment from 2.29.4 to 2.30.1 in [#373](docker/metadata-action#373)
- Bump moment-timezone from 0.5.43 to 0.5.44 in [#374](docker/metadata-action#374)

**Full Changelog**: <docker/metadata-action@v5.4.0...v5.5.0>

---
##### [\`v5.4.0\`](https://github.com/docker/metadata-action/releases/tag/v5.4.0)

- Bump [@docker/actions-toolkit](https://github.com/docker/actions-toolkit) from 0.15.0 to 0.16.0 in [#369](docker/metadata-action#369)
- Bump csv-parse from 5.5.2 to 5.5.3 in [#365](docker/metadata-action#365)

**Full Changelog**: <docker/metadata-action@v5.3.0...v5.4.0>

---
##### [\`v5.3.0\`](https://github.com/docker/metadata-action/releases/tag/v5.3.0)

- Bump [@docker/actions-toolkit](https://github.com/docker/actions-toolkit) from 0.14.0 to 0.15.0 in [#363](docker/metadata-action#363) (fixes [#362](docker/metadata-action#362))

**Full Changelog**: <docker/metadata-action@v5.2.0...v5.3.0>

---
##### [\`v5.2.0\`](https://github.com/docker/metadata-action/releases/tag/v5.2.0)

- Custom annotations support by [@crazy-max](https://github.com/crazy-max) in [#361](docker/metadata-action#361)

**Full Changelog**: <docker/metadata-action@v5.1.0...v5.2.0>

---
##### [\`v5.1.0\`](https://github.com/docker/metadata-action/releases/tag/v5.1.0)

- Annotations support by [@crazy-max](https://github.com/crazy-max) in [#352](docker/metadata-action#352)
- Split bake definition into two files by [@crazy-max](https://github.com/crazy-max) in [#353](docker/metadata-action#353)
- Allow images input to be empty to output bare tags by [@crazy-max](https://github.com/crazy-max) in [#358](docker/metadata-action#358)
- Bump [@actions/github](https://github.com/actions/github) from 5.1.1 to 6.0.0 in [#348](docker/metadata-action#348)
- Bump [@babel/traverse](https://github.com/babel/traverse) from 7.17.3 to 7.23.2 in [#350](docker/metadata-action#350)
- Bump [@docker/actions-toolkit](https://github.com/docker/actions-toolkit) from 0.12.0 to 0.14.0 in [#349](docker/metadata-action#349) [#357](docker/metadata-action#357)
- Bump csv-parse from 5.5.0 to 5.5.2 in [#346](docker/metadata-action#346)
- Bump semver from 7.5.3 to 7.5.4 in [#335](docker/metadata-action#335)

**Full Changelog**: <docker/metadata-action@v5.0.0...v5.1.0>
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