mirror of
https://github.com/redhat-actions/push-to-registry.git
synced 2025-02-22 02:01:21 +01:00
first implementation push to quay action
Signed-off-by: Luca Stocchi <lstocchi@redhat.com>
This commit is contained in:
commit
9a0a0927cd
11 changed files with 4046 additions and 0 deletions
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
node_modules/
|
||||
out/
|
21
LICENSE
Normal file
21
LICENSE
Normal file
|
@ -0,0 +1,21 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) 2020 Red Hat. All rights reserved.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE
|
1
README.md
Normal file
1
README.md
Normal file
|
@ -0,0 +1 @@
|
|||
In testing
|
22
action.yml
Normal file
22
action.yml
Normal file
|
@ -0,0 +1,22 @@
|
|||
name: 'Lucas Test Push To Quay Action'
|
||||
description: 'This action allows you to push an image to Quay'
|
||||
author: 'Luca'
|
||||
branding:
|
||||
icon: circle
|
||||
color: red
|
||||
inputs:
|
||||
image-to-push:
|
||||
description: 'Name of the new image that will be pushed'
|
||||
required: true
|
||||
quay-registry:
|
||||
description: 'Quay repo where to push the image'
|
||||
required: true
|
||||
username:
|
||||
description: 'Username to use as credential to authenticate to the registry'
|
||||
required: true
|
||||
password:
|
||||
description: 'Password to use as credential to authenticate to the registry'
|
||||
required: true
|
||||
runs:
|
||||
using: 'node12'
|
||||
main: 'dist/index.js'
|
2
dist/index.js
vendored
Normal file
2
dist/index.js
vendored
Normal file
File diff suppressed because one or more lines are too long
1
dist/index.js.map
vendored
Normal file
1
dist/index.js.map
vendored
Normal file
File diff suppressed because one or more lines are too long
3910
dist/sourcemap-register.js
vendored
Normal file
3910
dist/sourcemap-register.js
vendored
Normal file
File diff suppressed because it is too large
Load diff
23
package.json
Normal file
23
package.json
Normal file
|
@ -0,0 +1,23 @@
|
|||
{
|
||||
"name": "push-to-quay-action",
|
||||
"version": "0.0.1",
|
||||
"description": "Action to push images to quay",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"compile": "tsc -p .",
|
||||
"bundle": "ncc build src/index.ts --source-map --minify",
|
||||
"clean": "rm -rf out/ dist/",
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"author": "Luca",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@actions/core": "^1.2.6",
|
||||
"@actions/exec": "^1.0.4",
|
||||
"@actions/io": "^1.0.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^12.12.7",
|
||||
"typescript": "^4.0.5"
|
||||
}
|
||||
}
|
39
src/index.ts
Normal file
39
src/index.ts
Normal file
|
@ -0,0 +1,39 @@
|
|||
import * as core from '@actions/core';
|
||||
import * as exec from '@actions/exec';
|
||||
import * as io from '@actions/io';
|
||||
import { CommandResult } from './types';
|
||||
|
||||
export async function run(): Promise<void> {
|
||||
const imageToPush = core.getInput('image-to-push');
|
||||
const quayRegistry = core.getInput('quay-registry');
|
||||
const username = core.getInput('username');
|
||||
const password = core.getInput('password');
|
||||
|
||||
// get podman cli
|
||||
const podman = await io.which('podman', true);
|
||||
|
||||
// push image
|
||||
const push: CommandResult = await execute(podman, ['push', '--creds', `${username}:${password}`, `${imageToPush}`, `${quayRegistry}`]);
|
||||
if (push.succeeded === false) {
|
||||
return Promise.reject(new Error(push.reason));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
async function execute(executable: string, args: string[]): Promise<CommandResult> {
|
||||
let error = '';
|
||||
|
||||
const options: exec.ExecOptions = {};
|
||||
options.listeners = {
|
||||
stderr: (data: Buffer): void => {
|
||||
error += data.toString();
|
||||
}
|
||||
};
|
||||
const exitCode = await exec.exec(this.executable, args, options);
|
||||
if (exitCode === 1) {
|
||||
return Promise.resolve({ succeeded: false, error: error });
|
||||
}
|
||||
return Promise.resolve({ succeeded: true });
|
||||
}
|
||||
|
||||
run().catch(core.setFailed);
|
11
src/types.ts
Normal file
11
src/types.ts
Normal file
|
@ -0,0 +1,11 @@
|
|||
export interface CommandSucceeeded {
|
||||
readonly succeeded: true;
|
||||
readonly output?: string;
|
||||
}
|
||||
|
||||
export interface CommandFailed {
|
||||
readonly succeeded: false;
|
||||
readonly reason?: string;
|
||||
}
|
||||
|
||||
export type CommandResult = CommandFailed | CommandSucceeeded;
|
14
tsconfig.json
Normal file
14
tsconfig.json
Normal file
|
@ -0,0 +1,14 @@
|
|||
{
|
||||
"compilerOptions": {
|
||||
"target": "ES6",
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"ES2017"
|
||||
],
|
||||
"outDir": "out",
|
||||
"rootDir": ".",
|
||||
},
|
||||
"exclude": [
|
||||
"node_modules"
|
||||
]
|
||||
}
|
Loading…
Add table
Reference in a new issue