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

Wait for head SHA on pull request #24

Merged
merged 2 commits into from
Oct 13, 2022
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 10 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,13 @@ This actions depends on `docker pull` and `docker image inspect` command.

### Inputs

| Name | Default | Description |
| ------------------- | ------------ | ------------------------------------- |
| `tags` | (required) | Docker image tags |
| `expected-revision` | `github.sha` | Expected Git revision of Docker image |
| `timeout-seconds` | 600 | Timeout |
| `polling-seconds` | 5 | Polling interval |
| Name | Default | Description |
| ------------------- | ----------- | -------------------------------------- |
| `tags` | (required) | Docker image tags |
| `expected-revision` | (see below) | Expected Git revisions of Docker image |
| `timeout-seconds` | 600 | Timeout |
| `polling-seconds` | 5 | Polling interval |

By default, this action waits until the revision is `github.sha` or `github.event.pull_request.head.sha`.
Since [docker/metadata-action@v4.1.0](https://github.com/docker/metadata-action/releases/tag/v4.1.0),
it generates the head sha on pull request event (see also [the issue](https://github.com/docker/metadata-action/issues/206)).
6 changes: 4 additions & 2 deletions action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@ inputs:
description: Docker tags (multi-line string)
required: true
expected-revision:
description: expected Git revision
description: expected Git revisions (multi-line string)
required: true
default: ${{ github.sha }}
default: |-
${{ github.sha }}
${{ github.event.pull_request.head.sha }}
timeout-seconds:
description: timeout in seconds
required: true
Expand Down
2 changes: 1 addition & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { run } from './run'
const main = async (): Promise<void> => {
await run({
tags: core.getMultilineInput('tags', { required: true }),
expectedRevision: core.getInput('expected-revision', { required: true }),
expectedRevisions: core.getMultilineInput('expected-revision', { required: true }),
timeoutSeconds: parseInt(core.getInput('timeout-seconds', { required: true })),
pollingSeconds: parseInt(core.getInput('polling-seconds', { required: true })),
})
Expand Down
7 changes: 4 additions & 3 deletions src/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import * as exec from '@actions/exec'

type Inputs = {
tags: string[]
expectedRevision: string
expectedRevisions: string[]
timeoutSeconds: number
pollingSeconds: number
}
Expand All @@ -22,9 +22,10 @@ export const run = async (inputs: Inputs): Promise<void> => {
const checkIfDockerImageRevisionIsExpected = async (inputs: Inputs): Promise<boolean> => {
for (const tag of inputs.tags) {
const revision = await getDockerImageRevision(tag)
if (revision !== inputs.expectedRevision) {
return false
if (revision && inputs.expectedRevisions.includes(revision)) {
continue
}
return false
}
return true
}
Expand Down