mirror of
https://github.com/redhat-actions/push-to-registry.git
synced 2025-02-22 18:21:20 +01:00
Add IO generator and CI checks (#21)
* Add IO generator and CI checks * Update Buildah build action to use v2 tag Signed-off-by: divyansh42 <diagrawa@redhat.com>
This commit is contained in:
parent
870f44bc9b
commit
4757eb3399
11 changed files with 160 additions and 35 deletions
48
.github/workflows/ci.yml
vendored
Normal file
48
.github/workflows/ci.yml
vendored
Normal file
|
@ -0,0 +1,48 @@
|
|||
name: CI checks
|
||||
on:
|
||||
push:
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
lint:
|
||||
name: Run ESLint
|
||||
runs-on: ubuntu-20.04
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- run: npm ci
|
||||
- run: npm run lint
|
||||
|
||||
check-dist:
|
||||
name: Check Distribution
|
||||
runs-on: ubuntu-20.04
|
||||
env:
|
||||
BUNDLE_FILE: "dist/index.js"
|
||||
BUNDLE_COMMAND: "npm run bundle"
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- name: Install
|
||||
run: npm ci
|
||||
|
||||
- name: Verify Latest Bundle
|
||||
uses: redhat-actions/common/bundle-verifier@v1
|
||||
with:
|
||||
bundle_file: ${{ env.BUNDLE_FILE }}
|
||||
bundle_command: ${{ env.BUNDLE_COMMAND }}
|
||||
|
||||
check-inputs-outputs:
|
||||
name: Check Input and Output enums
|
||||
runs-on: ubuntu-20.04
|
||||
env:
|
||||
IO_FILE: ./src/generated/inputs-outputs.ts
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- name: Install dependencies
|
||||
run: npm ci
|
||||
|
||||
- name: Verify Input and Output enums
|
||||
uses: redhat-actions/common/action-io-generator@v1
|
||||
with:
|
||||
io_file: ${{ env.IO_FILE }}
|
22
.github/workflows/verify-bundle.yml
vendored
22
.github/workflows/verify-bundle.yml
vendored
|
@ -1,22 +0,0 @@
|
|||
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"
|
2
.github/workflows/verify-push.yaml
vendored
2
.github/workflows/verify-push.yaml
vendored
|
@ -67,7 +67,7 @@ jobs:
|
|||
# Build image using Buildah action
|
||||
- name: Build Image
|
||||
id: build_image
|
||||
uses: redhat-actions/buildah-build@main
|
||||
uses: redhat-actions/buildah-build@v2
|
||||
with:
|
||||
image: ${{ env.IMAGE_NAME }}
|
||||
tags: ${{ env.IMAGE_TAGS }}
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
# 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/actions?query=workflow%3A%22CI+checks%22)
|
||||
[](https://github.com/redhat-actions/push-to-registry/actions?query=workflow%3A%22Test+Build+and+Push%22)
|
||||
[](https://github.com/redhat-actions/push-to-registry/actions?query=workflow%3A%22Multiple+container+CLI+build+tests%22)
|
||||
<br><br>
|
||||
[](https://github.com/redhat-actions/push-to-registry/tags)
|
||||
[](./LICENSE)
|
||||
[](./dist)
|
||||
|
|
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
15
git-hooks/pre-commit
Normal file
15
git-hooks/pre-commit
Normal file
|
@ -0,0 +1,15 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
### Copy this into .git/hooks and overwrite the empty one.
|
||||
### This will ensure the bundle and ins-outs verification checks won't fail for you.
|
||||
|
||||
echo "----- Pre-commit -----"
|
||||
set -ex
|
||||
npx action-io-generator -o src/generated/inputs-outputs.ts
|
||||
npm run lint
|
||||
npm run bundle
|
||||
git add -v dist/ src/generated
|
||||
|
||||
set +x
|
||||
|
||||
echo "Success"
|
10
package-lock.json
generated
10
package-lock.json
generated
|
@ -113,6 +113,16 @@
|
|||
"fastq": "^1.6.0"
|
||||
}
|
||||
},
|
||||
"@redhat-actions/action-io-generator": {
|
||||
"version": "1.5.0",
|
||||
"resolved": "https://registry.npmjs.org/@redhat-actions/action-io-generator/-/action-io-generator-1.5.0.tgz",
|
||||
"integrity": "sha512-zaBZyP0ev5c36j0h8EyvqbD+fhUjDOeme2qzVa+CSWjeGVAsgdZREzE8smE3QA6xXpMHPU5keT+q2iN8/hq5uA==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"js-yaml": "^3.14.1",
|
||||
"minimist": "^1.2.5"
|
||||
}
|
||||
},
|
||||
"@redhat-actions/eslint-config": {
|
||||
"version": "1.2.11",
|
||||
"resolved": "https://registry.npmjs.org/@redhat-actions/eslint-config/-/eslint-config-1.2.11.tgz",
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
"@actions/io": "^1.0.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@redhat-actions/action-io-generator": "^1.5.0",
|
||||
"@redhat-actions/eslint-config": "^1.2.11",
|
||||
"@redhat-actions/tsconfig": "^1.1.0",
|
||||
"@types/node": "^12.12.7",
|
||||
|
|
69
src/generated/inputs-outputs.ts
Normal file
69
src/generated/inputs-outputs.ts
Normal file
|
@ -0,0 +1,69 @@
|
|||
// This file was auto-generated by action-io-generator. Do not edit by hand!
|
||||
export enum Inputs {
|
||||
/**
|
||||
* After copying the image, write the digest of the resulting image to the file.
|
||||
* By default, the filename will be determined from the image and tag.
|
||||
* The contents of this file are the digest output.
|
||||
* Required: false
|
||||
* Default: None.
|
||||
*/
|
||||
DIGESTFILE = "digestfile",
|
||||
/**
|
||||
* Extra args to be passed to podman push.
|
||||
* Separate arguments by newline. Do not use quotes - @actions/exec will do the quoting for you.
|
||||
* Required: false
|
||||
* Default: None.
|
||||
*/
|
||||
EXTRA_ARGS = "extra-args",
|
||||
/**
|
||||
* Name of the image to push
|
||||
* Required: true
|
||||
* Default: None.
|
||||
*/
|
||||
IMAGE = "image",
|
||||
/**
|
||||
* Password to use as credential to authenticate to the registry
|
||||
* Required: true
|
||||
* Default: None.
|
||||
*/
|
||||
PASSWORD = "password",
|
||||
/**
|
||||
* Registry where to push the image (eg. quay.io/username)
|
||||
* Required: true
|
||||
* Default: None.
|
||||
*/
|
||||
REGISTRY = "registry",
|
||||
/**
|
||||
* The tag or tags of the image to push. For multiple tags, seperate by a space. For example, "latest v1"
|
||||
* Required: false
|
||||
* Default: "latest"
|
||||
*/
|
||||
TAGS = "tags",
|
||||
/**
|
||||
* Verify TLS certificates when contacting the registry
|
||||
* Required: false
|
||||
* Default: "true"
|
||||
*/
|
||||
TLS_VERIFY = "tls-verify",
|
||||
/**
|
||||
* Username to use as credential to authenticate to the registry
|
||||
* Required: true
|
||||
* Default: None.
|
||||
*/
|
||||
USERNAME = "username",
|
||||
}
|
||||
|
||||
export enum Outputs {
|
||||
/**
|
||||
* The pushed image digest, as written to the "digestfile"
|
||||
* Required: false
|
||||
* Default: None.
|
||||
*/
|
||||
DIGEST = "digest",
|
||||
/**
|
||||
* A JSON array of registry paths to which the tag(s) were pushed
|
||||
* Required: false
|
||||
* Default: None.
|
||||
*/
|
||||
REGISTRY_PATHS = "registry-paths",
|
||||
}
|
19
src/index.ts
19
src/index.ts
|
@ -4,6 +4,7 @@ import * as io from "@actions/io";
|
|||
import * as fs from "fs";
|
||||
import * as path from "path";
|
||||
import { splitByNewline } from "./util";
|
||||
import { Inputs, Outputs } from "./generated/inputs-outputs";
|
||||
|
||||
interface ExecResult {
|
||||
exitCode: number;
|
||||
|
@ -35,15 +36,15 @@ async function getPodmanPath(): Promise<string> {
|
|||
const dockerBaseUrl = "docker.io/library";
|
||||
|
||||
async function run(): Promise<void> {
|
||||
const imageInput = core.getInput("image", { required: true });
|
||||
const tags = core.getInput("tags") || "latest";
|
||||
const imageInput = core.getInput(Inputs.IMAGE, { required: true });
|
||||
const tags = core.getInput(Inputs.TAGS) || "latest";
|
||||
// split tags
|
||||
tagsList = tags.split(" ");
|
||||
const registry = core.getInput("registry", { required: true });
|
||||
const username = core.getInput("username", { required: true });
|
||||
const password = core.getInput("password", { required: true });
|
||||
const tlsVerify = core.getInput("tls-verify");
|
||||
const digestFileInput = core.getInput("digestfile");
|
||||
const registry = core.getInput(Inputs.REGISTRY, { required: true });
|
||||
const username = core.getInput(Inputs.USERNAME, { required: true });
|
||||
const password = core.getInput(Inputs.PASSWORD, { required: true });
|
||||
const tlsVerify = core.getInput(Inputs.TLS_VERIFY);
|
||||
const digestFileInput = core.getInput(Inputs.DIGESTFILE);
|
||||
|
||||
const inputExtraArgsStr = core.getInput("extra-args");
|
||||
let podmanExtraArgs: string[] = [];
|
||||
|
@ -187,13 +188,13 @@ async function run(): Promise<void> {
|
|||
try {
|
||||
const digest = (await fs.promises.readFile(digestFile)).toString();
|
||||
core.info(digest);
|
||||
core.setOutput("digest", digest);
|
||||
core.setOutput(Outputs.DIGEST, digest);
|
||||
}
|
||||
catch (err) {
|
||||
core.warning(`Failed to read digest file "${digestFile}": ${err}`);
|
||||
}
|
||||
|
||||
core.setOutput("registry-paths", JSON.stringify(registryPathList));
|
||||
core.setOutput(Outputs.REGISTRY_PATHS, JSON.stringify(registryPathList));
|
||||
}
|
||||
|
||||
async function pullImageFromDocker(): Promise<ImageStorageCheckResult> {
|
||||
|
|
Loading…
Add table
Reference in a new issue