mirror of
https://github.com/redhat-actions/push-to-registry.git
synced 2025-02-22 18:21:20 +01:00
Add verify bundle action and make inputs 'required'
Signed-off-by: Tim Etchells <tetchell@redhat.com>
This commit is contained in:
parent
05f033c95a
commit
61095317bf
8 changed files with 86 additions and 18 deletions
22
.github/workflows/verify-bundle.yml
vendored
Normal file
22
.github/workflows/verify-bundle.yml
vendored
Normal file
|
@ -0,0 +1,22 @@
|
|||
name: Verify Bundle
|
||||
on: [ push, pull_request ]
|
||||
|
||||
jobs:
|
||||
verify-bundle:
|
||||
name: Verify Distribution Bundle
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
env:
|
||||
DEFAULT_BRANCH: main
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Install dependencies
|
||||
run: npm ci
|
||||
|
||||
- name: Check Distribution
|
||||
uses: tetchel/bundle-verifier-action@v0.0.2
|
||||
with:
|
||||
bundle_file: dist/index.js
|
||||
bundle_command: "npm run bundle"
|
|
@ -1,5 +1,6 @@
|
|||
# push-to-registry
|
||||
|
||||
[](https://github.com/redhat-actions/push-to-registry/actions?query=workflow%3A%22Verify+Bundle%22)
|
||||
[](https://github.com/redhat-actions/push-to-registry/tags)
|
||||
[](./LICENSE)
|
||||
[](./dist)
|
||||
|
@ -18,7 +19,7 @@ Push-to-registry is a GitHub Action for pushing an OCI-compatible image to an im
|
|||
</thead>
|
||||
|
||||
<tr>
|
||||
<td>image-to-push</td>
|
||||
<td>image</td>
|
||||
<td>Yes</td>
|
||||
<td>
|
||||
Name of the image you want to push. Most likely the name you used to create the image in the previous step.
|
||||
|
@ -92,7 +93,7 @@ jobs:
|
|||
- name: Push To Quay
|
||||
uses: redhat-actions/push-to-registry@0.0.1
|
||||
with:
|
||||
image-to-push: ${{ env.IMAGE_NAME }}
|
||||
image: ${{ env.IMAGE_NAME }}
|
||||
registry: ${{ secrets.QUAY_REPO }}
|
||||
username: ${{ secrets.QUAY_USERNAME }}
|
||||
password: ${{ secrets.QUAY_TOKEN }}
|
||||
|
|
10
action.yml
10
action.yml
|
@ -5,15 +5,15 @@ branding:
|
|||
icon: circle
|
||||
color: red
|
||||
inputs:
|
||||
image-to-push:
|
||||
description: 'Name of the new image that will be pushed'
|
||||
image:
|
||||
description: 'Name of the image to push'
|
||||
required: true
|
||||
tag:
|
||||
description: 'Tag of the new image'
|
||||
description: 'Tag of the image to push'
|
||||
required: false
|
||||
default: 'latest'
|
||||
registry:
|
||||
description: 'Registry where to push the image (e.g quay.io/username)'
|
||||
description: 'Registry where to push the image (eg. quay.io/username)'
|
||||
required: true
|
||||
username:
|
||||
description: 'Username to use as credential to authenticate to the registry'
|
||||
|
@ -23,4 +23,4 @@ inputs:
|
|||
required: true
|
||||
runs:
|
||||
using: 'node12'
|
||||
main: 'dist/index.js'
|
||||
main: 'dist/index.js'
|
||||
|
|
2
dist/index.js
vendored
2
dist/index.js
vendored
File diff suppressed because one or more lines are too long
2
dist/index.js.map
vendored
2
dist/index.js.map
vendored
File diff suppressed because one or more lines are too long
44
package-lock.json
generated
Normal file
44
package-lock.json
generated
Normal file
|
@ -0,0 +1,44 @@
|
|||
{
|
||||
"name": "push-to-registry",
|
||||
"version": "0.0.1",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
"@actions/core": {
|
||||
"version": "1.2.6",
|
||||
"resolved": "https://registry.npmjs.org/@actions/core/-/core-1.2.6.tgz",
|
||||
"integrity": "sha512-ZQYitnqiyBc3D+k7LsgSBmMDVkOVidaagDG7j3fOym77jNunWRuYx7VSHa9GNfFZh+zh61xsCjRj4JxMZlDqTA=="
|
||||
},
|
||||
"@actions/exec": {
|
||||
"version": "1.0.4",
|
||||
"resolved": "https://registry.npmjs.org/@actions/exec/-/exec-1.0.4.tgz",
|
||||
"integrity": "sha512-4DPChWow9yc9W3WqEbUj8Nr86xkpyE29ZzWjXucHItclLbEW6jr80Zx4nqv18QL6KK65+cifiQZXvnqgTV6oHw==",
|
||||
"requires": {
|
||||
"@actions/io": "^1.0.1"
|
||||
}
|
||||
},
|
||||
"@actions/io": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/@actions/io/-/io-1.0.2.tgz",
|
||||
"integrity": "sha512-J8KuFqVPr3p6U8W93DOXlXW6zFvrQAJANdS+vw0YhusLIq+bszW8zmK2Fh1C2kDPX8FMvwIl1OUcFgvJoXLbAg=="
|
||||
},
|
||||
"@types/node": {
|
||||
"version": "12.19.4",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-12.19.4.tgz",
|
||||
"integrity": "sha512-o3oj1bETk8kBwzz1WlO6JWL/AfAA3Vm6J1B3C9CsdxHYp7XgPiH7OEXPUbZTndHlRaIElrANkQfe6ZmfJb3H2w==",
|
||||
"dev": true
|
||||
},
|
||||
"@vercel/ncc": {
|
||||
"version": "0.25.1",
|
||||
"resolved": "https://registry.npmjs.org/@vercel/ncc/-/ncc-0.25.1.tgz",
|
||||
"integrity": "sha512-dGecC5+1wLof1MQpey4+6i2KZv4Sfs6WfXkl9KfO32GED4ZPiKxRfvtGPjbjZv0IbqMl6CxtcV1RotXYfd5SSA==",
|
||||
"dev": true
|
||||
},
|
||||
"typescript": {
|
||||
"version": "4.0.5",
|
||||
"resolved": "https://registry.npmjs.org/typescript/-/typescript-4.0.5.tgz",
|
||||
"integrity": "sha512-ywmr/VrTVCmNTJ6iV2LwIrfG1P+lv6luD8sUJs+2eI9NLGigaN+nUQc13iHqisq7bra9lnmUSYqbJvegraBOPQ==",
|
||||
"dev": true
|
||||
}
|
||||
}
|
||||
}
|
|
@ -18,6 +18,7 @@
|
|||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^12.12.7",
|
||||
"@vercel/ncc": "^0.25.1",
|
||||
"typescript": "^4.0.5"
|
||||
}
|
||||
}
|
||||
|
|
18
src/index.ts
18
src/index.ts
|
@ -4,11 +4,11 @@ import * as io from '@actions/io';
|
|||
import { CommandResult } from './types';
|
||||
|
||||
export async function run(): Promise<void> {
|
||||
let imageToPush = core.getInput('image-to-push');
|
||||
let imageToPush = core.getInput('image', { required: true });
|
||||
const tag = core.getInput('tag') || 'latest';
|
||||
const registry = core.getInput('registry');
|
||||
const username = core.getInput('username');
|
||||
const password = core.getInput('password');
|
||||
const registry = core.getInput('registry', { required: true });
|
||||
const username = core.getInput('username', { required: true });
|
||||
const password = core.getInput('password', { required: true });
|
||||
|
||||
// get podman cli
|
||||
const podman = await io.which('podman', true);
|
||||
|
@ -18,9 +18,9 @@ export async function run(): Promise<void> {
|
|||
const checkImages: CommandResult = await execute(podman, ['images', '--format', 'json']);
|
||||
if (checkImages.succeeded === false) {
|
||||
return Promise.reject(new Error(checkImages.reason));
|
||||
}
|
||||
}
|
||||
const parsedCheckImages = JSON.parse(checkImages.output);
|
||||
// this is to temporarily solve an issue with the case-sensitive of the property field name. i.e it is Names or names??
|
||||
// this is to temporarily solve an issue with the case-sensitive of the property field name. i.e it is Names or names??
|
||||
const nameKeyMixedCase = parsedCheckImages[0] && Object.keys(parsedCheckImages[0]).find(key => 'names' === key.toLowerCase());
|
||||
const imagesFound = parsedCheckImages.
|
||||
filter(image => image[nameKeyMixedCase] && image[nameKeyMixedCase].find(name => name.includes(`${imageToPush}`))).
|
||||
|
@ -44,7 +44,7 @@ export async function run(): Promise<void> {
|
|||
async function execute(executable: string, args: string[]): Promise<CommandResult> {
|
||||
let output = '';
|
||||
let error = '';
|
||||
|
||||
|
||||
const options: exec.ExecOptions = {};
|
||||
options.listeners = {
|
||||
stdout: (data: Buffer): void => {
|
||||
|
@ -57,8 +57,8 @@ async function execute(executable: string, args: string[]): Promise<CommandResul
|
|||
const exitCode = await exec.exec(executable, args, options);
|
||||
if (exitCode === 1) {
|
||||
return Promise.resolve({ succeeded: false, error });
|
||||
}
|
||||
}
|
||||
return Promise.resolve({ succeeded: true, output });
|
||||
}
|
||||
|
||||
run().catch(core.setFailed);
|
||||
run().catch(core.setFailed);
|
||||
|
|
Loading…
Add table
Reference in a new issue