mirror of
https://github.com/redhat-actions/buildah-build.git
synced 2025-04-18 00:21:22 +00:00
Compare commits
13 commits
Author | SHA1 | Date | |
---|---|---|---|
|
7a95fa7ee0 | ||
|
1ec5690277 | ||
|
c79846fb30 | ||
|
b4dc19b4ba | ||
|
5f55f580e1 | ||
|
6c6c802bcc | ||
|
3e3409a032 | ||
|
5177407148 | ||
|
4b8d36793b | ||
|
807a385655 | ||
|
ea6be4fe0d | ||
|
ab528f78d0 | ||
|
2cb54cfbef |
21 changed files with 3634 additions and 4989 deletions
15
.editorconfig
Normal file
15
.editorconfig
Normal file
|
@ -0,0 +1,15 @@
|
|||
root = true
|
||||
|
||||
[*]
|
||||
charset = utf-8
|
||||
tab_width = 4
|
||||
indent_size = 4
|
||||
end_of_line = lf
|
||||
indent_style = space
|
||||
max_line_length = 120
|
||||
insert_final_newline = true
|
||||
trim_trailing_whitespace = true
|
||||
|
||||
[*.{yml,yaml}]
|
||||
tab_width = 2
|
||||
indent_size = 2
|
4
.github/workflows/check-lowercase.yaml
vendored
4
.github/workflows/check-lowercase.yaml
vendored
|
@ -16,7 +16,7 @@ env:
|
|||
jobs:
|
||||
build:
|
||||
name: Build image using Buildah
|
||||
runs-on: ubuntu-20.04
|
||||
runs-on: ubuntu-22.04
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
|
@ -26,7 +26,7 @@ jobs:
|
|||
|
||||
# Checkout buildah action github repository
|
||||
- name: Checkout Buildah action
|
||||
uses: actions/checkout@v2
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
path: "buildah-build"
|
||||
|
||||
|
|
18
.github/workflows/ci.yml
vendored
18
.github/workflows/ci.yml
vendored
|
@ -6,21 +6,21 @@ on:
|
|||
jobs:
|
||||
lint:
|
||||
name: Run ESLint
|
||||
runs-on: ubuntu-20.04
|
||||
runs-on: ubuntu-22.04
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v4
|
||||
- run: npm ci
|
||||
- run: npm run lint
|
||||
|
||||
|
||||
check-dist:
|
||||
name: Check Distribution
|
||||
runs-on: ubuntu-20.04
|
||||
runs-on: ubuntu-22.04
|
||||
env:
|
||||
BUNDLE_FILE: "dist/index.js"
|
||||
BUNDLE_COMMAND: "npm run bundle"
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Install
|
||||
run: npm ci
|
||||
|
@ -30,18 +30,18 @@ jobs:
|
|||
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
|
||||
runs-on: ubuntu-22.04
|
||||
env:
|
||||
IO_FILE: ./src/generated/inputs-outputs.ts
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Install dependencies
|
||||
run: npm ci
|
||||
|
||||
|
||||
- name: Verify Input and Output enums
|
||||
uses: redhat-actions/common/action-io-generator@v1
|
||||
with:
|
||||
|
|
4
.github/workflows/containerfile_build.yml
vendored
4
.github/workflows/containerfile_build.yml
vendored
|
@ -15,7 +15,7 @@ env:
|
|||
jobs:
|
||||
build:
|
||||
name: Build image using Buildah
|
||||
runs-on: ubuntu-20.04
|
||||
runs-on: ubuntu-22.04
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
|
@ -25,7 +25,7 @@ jobs:
|
|||
|
||||
# Checkout buildah action github repository
|
||||
- name: Checkout Buildah action
|
||||
uses: actions/checkout@v2
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
path: "buildah-build"
|
||||
|
||||
|
|
45
.github/workflows/docker_metadata_action.yml
vendored
45
.github/workflows/docker_metadata_action.yml
vendored
|
@ -1,7 +1,7 @@
|
|||
# This workflow will perform a test whenever there
|
||||
# is some change in code done to ensure that the changes
|
||||
# are not buggy and we are getting the desired output.
|
||||
name: Build with docker/metadata-action@v2
|
||||
name: Build with docker/metadata-action
|
||||
on:
|
||||
push:
|
||||
pull_request:
|
||||
|
@ -12,7 +12,7 @@ on:
|
|||
jobs:
|
||||
build-containerfile:
|
||||
name: Build image with Containerfile
|
||||
runs-on: ubuntu-20.04
|
||||
runs-on: ubuntu-22.04
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
|
@ -25,11 +25,11 @@ jobs:
|
|||
|
||||
# Checkout buildah action github repository
|
||||
- name: Checkout Buildah action
|
||||
uses: actions/checkout@v2
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Docker Metadata
|
||||
id: docker-metadata
|
||||
uses: docker/metadata-action@v3
|
||||
uses: docker/metadata-action@v4
|
||||
with:
|
||||
images: |
|
||||
${{ env.IMAGE_NAME }}
|
||||
|
@ -88,7 +88,7 @@ jobs:
|
|||
|
||||
build-scratch:
|
||||
name: Build image without Containerfile
|
||||
runs-on: ubuntu-20.04
|
||||
runs-on: ubuntu-22.04
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
|
@ -103,11 +103,11 @@ jobs:
|
|||
|
||||
# Checkout buildah action github repository
|
||||
- name: Checkout Buildah action
|
||||
uses: actions/checkout@v2
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Docker Metadata
|
||||
id: docker-metadata
|
||||
uses: docker/metadata-action@v3
|
||||
uses: docker/metadata-action@v4
|
||||
with:
|
||||
images: |
|
||||
${{ env.IMAGE_NAME }}
|
||||
|
@ -128,31 +128,18 @@ jobs:
|
|||
|
||||
# Checkout spring-petclinic github repository
|
||||
- name: Checkout spring-petclinic project
|
||||
uses: actions/checkout@v2
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
repository: "spring-projects/spring-petclinic"
|
||||
path: ${{ env.PROJECT_DIR }}
|
||||
|
||||
# If none of these files has changed, we assume that the contents of
|
||||
# .m2/repository can be fetched from the cache.
|
||||
- name: Hash Maven files
|
||||
working-directory: ${{ env.PROJECT_DIR }}
|
||||
run: |
|
||||
echo "MVN_HASH=${{ hashFiles('**/pom.xml', '.mvn/**/*', 'mvnw*') }}" >> $GITHUB_ENV
|
||||
|
||||
# Download the m2 repository from the cache to speed up the build.
|
||||
- name: Check for Maven cache
|
||||
id: check-mvn-cache
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: ${{ env.MVN_REPO_DIR }}
|
||||
key: ${{ env.MVN_HASH }}
|
||||
|
||||
# Setup java.
|
||||
- name: Setup Java
|
||||
uses: actions/setup-java@v1
|
||||
uses: actions/setup-java@v3
|
||||
with:
|
||||
java-version: 11
|
||||
distribution: 'temurin'
|
||||
java-version: '17'
|
||||
cache: 'maven'
|
||||
|
||||
# Run maven to build the project
|
||||
- name: Maven
|
||||
|
@ -160,14 +147,6 @@ jobs:
|
|||
run: |
|
||||
mvn package -ntp -B
|
||||
|
||||
# If there was no cache hit above, store the output into the cache now.
|
||||
- name: Save Maven repo into cache
|
||||
if: ${{ steps.check-mvn-cache.outputs.cache-hit }} != 'true'
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: ${{ env.MVN_REPO_DIR }}
|
||||
key: ${{ env.MVN_HASH }}
|
||||
|
||||
# Build image using Buildah action
|
||||
- name: Build Image
|
||||
id: build_image
|
||||
|
|
4
.github/workflows/link_check.yml
vendored
4
.github/workflows/link_check.yml
vendored
|
@ -12,9 +12,9 @@ on:
|
|||
jobs:
|
||||
markdown-link-check:
|
||||
name: Check links in markdown
|
||||
runs-on: ubuntu-20.04
|
||||
runs-on: ubuntu-22.04
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v4
|
||||
- uses: gaurav-nelson/github-action-markdown-link-check@v1
|
||||
with:
|
||||
use-verbose-mode: true
|
||||
|
|
45
.github/workflows/multiarch.yml
vendored
45
.github/workflows/multiarch.yml
vendored
|
@ -16,7 +16,7 @@ jobs:
|
|||
name: Build multi-architecture image using Containerfile
|
||||
env:
|
||||
IMAGE_NAME: hello-world-multiarch
|
||||
runs-on: ubuntu-20.04
|
||||
runs-on: ubuntu-22.04
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
|
@ -26,7 +26,7 @@ jobs:
|
|||
|
||||
# Checkout buildah action github repository
|
||||
- name: Checkout Buildah action
|
||||
uses: actions/checkout@v2
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
path: "buildah-build"
|
||||
|
||||
|
@ -84,7 +84,7 @@ jobs:
|
|||
name: Build multi-platform image using Containerfile
|
||||
env:
|
||||
IMAGE_NAME: hello-world-multiplatform
|
||||
runs-on: ubuntu-20.04
|
||||
runs-on: ubuntu-22.04
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
|
@ -94,7 +94,7 @@ jobs:
|
|||
|
||||
# Checkout buildah action github repository
|
||||
- name: Checkout Buildah action
|
||||
uses: actions/checkout@v2
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
path: "buildah-build"
|
||||
|
||||
|
@ -112,7 +112,7 @@ jobs:
|
|||
run: |
|
||||
cat > Containerfile<<EOF
|
||||
|
||||
FROM docker.io/alpine:3.14
|
||||
FROM docker.io/alpine:3.16
|
||||
|
||||
RUN echo "hello world"
|
||||
|
||||
|
@ -151,7 +151,7 @@ jobs:
|
|||
name: Build multi-architecture image from scratch
|
||||
env:
|
||||
IMAGE_NAME: spring-petclinic-multiarch
|
||||
runs-on: ubuntu-20.04
|
||||
runs-on: ubuntu-22.04
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
|
@ -161,7 +161,7 @@ jobs:
|
|||
|
||||
# Checkout buildah action github repository
|
||||
- name: Checkout Buildah action
|
||||
uses: actions/checkout@v2
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
path: "buildah-build"
|
||||
|
||||
|
@ -177,31 +177,18 @@ jobs:
|
|||
|
||||
# Checkout spring-petclinic github repository
|
||||
- name: Checkout spring-petclinic project
|
||||
uses: actions/checkout@v2
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
repository: "spring-projects/spring-petclinic"
|
||||
path: ${{ env.PROJECT_DIR }}
|
||||
|
||||
# If none of these files has changed, we assume that the contents of
|
||||
# .m2/repository can be fetched from the cache.
|
||||
- name: Hash Maven files
|
||||
working-directory: ${{ env.PROJECT_DIR }}
|
||||
run: |
|
||||
echo "MVN_HASH=${{ hashFiles('**/pom.xml', '.mvn/**/*', 'mvnw*') }}" >> $GITHUB_ENV
|
||||
|
||||
# Download the m2 repository from the cache to speed up the build.
|
||||
- name: Check for Maven cache
|
||||
id: check-mvn-cache
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: ${{ env.MVN_REPO_DIR }}
|
||||
key: ${{ env.MVN_HASH }}
|
||||
|
||||
# Setup java.
|
||||
- name: Setup Java
|
||||
uses: actions/setup-java@v1
|
||||
uses: actions/setup-java@v3
|
||||
with:
|
||||
java-version: 11
|
||||
distribution: 'temurin'
|
||||
java-version: '17'
|
||||
cache: 'maven'
|
||||
|
||||
# Run maven to build the project
|
||||
- name: Maven
|
||||
|
@ -209,14 +196,6 @@ jobs:
|
|||
run: |
|
||||
mvn package -ntp -B
|
||||
|
||||
# If there was no cache hit above, store the output into the cache now.
|
||||
- name: Save Maven repo into cache
|
||||
if: ${{ steps.check-mvn-cache.outputs.cache-hit }} != 'true'
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: ${{ env.MVN_REPO_DIR }}
|
||||
key: ${{ env.MVN_HASH }}
|
||||
|
||||
- name: Build Image
|
||||
id: build_image_multiarch
|
||||
uses: ./buildah-build/
|
||||
|
|
35
.github/workflows/scratch_build.yml
vendored
35
.github/workflows/scratch_build.yml
vendored
|
@ -17,7 +17,7 @@ env:
|
|||
jobs:
|
||||
build:
|
||||
name: Build image using Buildah
|
||||
runs-on: ubuntu-20.04
|
||||
runs-on: ubuntu-22.04
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
|
@ -27,7 +27,7 @@ jobs:
|
|||
|
||||
# Checkout buildah action github repository
|
||||
- name: Checkout Buildah action
|
||||
uses: actions/checkout@v2
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
path: "buildah-build"
|
||||
|
||||
|
@ -38,31 +38,18 @@ jobs:
|
|||
|
||||
# Checkout spring-petclinic github repository
|
||||
- name: Checkout spring-petclinic project
|
||||
uses: actions/checkout@v2
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
repository: "spring-projects/spring-petclinic"
|
||||
path: ${{ env.PROJECT_DIR }}
|
||||
|
||||
# If none of these files has changed, we assume that the contents of
|
||||
# .m2/repository can be fetched from the cache.
|
||||
- name: Hash Maven files
|
||||
working-directory: ${{ env.PROJECT_DIR }}
|
||||
run: |
|
||||
echo "MVN_HASH=${{ hashFiles('**/pom.xml', '.mvn/**/*', 'mvnw*') }}" >> $GITHUB_ENV
|
||||
|
||||
# Download the m2 repository from the cache to speed up the build.
|
||||
- name: Check for Maven cache
|
||||
id: check-mvn-cache
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: ${{ env.MVN_REPO_DIR }}
|
||||
key: ${{ env.MVN_HASH }}
|
||||
|
||||
# Setup java.
|
||||
- name: Setup Java
|
||||
uses: actions/setup-java@v1
|
||||
uses: actions/setup-java@v3
|
||||
with:
|
||||
java-version: 11
|
||||
distribution: 'temurin'
|
||||
java-version: '17'
|
||||
cache: 'maven'
|
||||
|
||||
# Run maven to build the project
|
||||
- name: Maven
|
||||
|
@ -70,14 +57,6 @@ jobs:
|
|||
run: |
|
||||
mvn package -ntp -B
|
||||
|
||||
# If there was no cache hit above, store the output into the cache now.
|
||||
- name: Save Maven repo into cache
|
||||
if: ${{ steps.check-mvn-cache.outputs.cache-hit }} != 'true'
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: ${{ env.MVN_REPO_DIR }}
|
||||
key: ${{ env.MVN_HASH }}
|
||||
|
||||
# Build image using Buildah action
|
||||
- name: Build Image
|
||||
id: build_image
|
||||
|
|
19
.github/workflows/security_scan.yml
vendored
19
.github/workflows/security_scan.yml
vendored
|
@ -1,24 +1,25 @@
|
|||
name: Vulnerability Scan with CRDA
|
||||
on:
|
||||
push:
|
||||
# push:
|
||||
workflow_dispatch:
|
||||
pull_request_target:
|
||||
types: [ assigned, opened, synchronize, reopened, labeled, edited ]
|
||||
schedule:
|
||||
- cron: '0 0 * * *' # every day at midnight
|
||||
# pull_request_target:
|
||||
# types: [ assigned, opened, synchronize, reopened, labeled, edited ]
|
||||
# schedule:
|
||||
# - cron: '0 0 * * *' # every day at midnight
|
||||
|
||||
jobs:
|
||||
crda-scan:
|
||||
runs-on: ubuntu-20.04
|
||||
runs-on: ubuntu-22.04
|
||||
name: Scan project vulnerability with CRDA
|
||||
steps:
|
||||
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Setup Node
|
||||
uses: actions/setup-node@v2
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: '14'
|
||||
node-version: '20'
|
||||
cache: 'npm'
|
||||
|
||||
- name: Install CRDA
|
||||
uses: redhat-actions/openshift-tools-installer@v1
|
||||
|
|
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -1,2 +1,3 @@
|
|||
node_modules/
|
||||
out/
|
||||
out/
|
||||
.idea/
|
||||
|
|
|
@ -1,5 +1,14 @@
|
|||
# buildah-build Changelog
|
||||
|
||||
## v2.13
|
||||
- Update action to run on Node20. https://github.blog/changelog/2023-09-22-github-actions-transitioning-from-node-16-to-node-20/
|
||||
|
||||
## v2.12
|
||||
- Forcibly remove existing manifest before creating a new one. [#103](https://github.com/redhat-actions/buildah-build/pull/103)
|
||||
|
||||
## v2.11
|
||||
- Update action to run on Node16. https://github.blog/changelog/2022-05-20-actions-can-now-run-in-a-node-js-16-runtime/
|
||||
|
||||
## v2.10
|
||||
- Make image and tag in lowercase, if found in uppercase. https://github.com/redhat-actions/buildah-build/issues/89
|
||||
- Add `--tls-verify` and `extra-args` input for `buildah from` command. https://github.com/redhat-actions/buildah-build/issues/92
|
||||
|
|
|
@ -126,7 +126,7 @@ jobs:
|
|||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Buildah Action
|
||||
uses: redhat-actions/buildah-build@v2
|
||||
|
@ -166,7 +166,7 @@ jobs:
|
|||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- run: mvn package
|
||||
|
||||
|
|
|
@ -90,5 +90,5 @@ outputs:
|
|||
image-with-tag:
|
||||
description: 'Name of the image tagged with the first tag present'
|
||||
runs:
|
||||
using: 'node12'
|
||||
using: 'node20'
|
||||
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
3911
dist/sourcemap-register.js
vendored
3911
dist/sourcemap-register.js
vendored
File diff suppressed because one or more lines are too long
4344
package-lock.json
generated
4344
package-lock.json
generated
File diff suppressed because it is too large
Load diff
32
package.json
32
package.json
|
@ -1,8 +1,8 @@
|
|||
{
|
||||
"name": "buildah-build",
|
||||
"version": "1.0.0",
|
||||
"version": "3.0",
|
||||
"engines": {
|
||||
"node": "12"
|
||||
"node": "20"
|
||||
},
|
||||
"description": "Action for building OCI-compatible images using buildah",
|
||||
"repository": {
|
||||
|
@ -21,21 +21,21 @@
|
|||
"author": "Red Hat",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@actions/core": "^1.2.6",
|
||||
"@actions/exec": "^1.0.4",
|
||||
"@actions/io": "^1.0.2",
|
||||
"ini": "^2.0.0"
|
||||
"@actions/core": "1.10.1",
|
||||
"@actions/exec": "1.1.1",
|
||||
"@actions/io": "1.1.3",
|
||||
"ini": "4.1.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@redhat-actions/action-io-generator": "^1.5.0",
|
||||
"@redhat-actions/eslint-config": "^1.3.2",
|
||||
"@redhat-actions/tsconfig": "^1.1.1",
|
||||
"@types/ini": "^1.3.30",
|
||||
"@types/node": "^12",
|
||||
"@typescript-eslint/eslint-plugin": "^4.28.2",
|
||||
"@typescript-eslint/parser": "^4.28.2",
|
||||
"@vercel/ncc": "^0.25.1",
|
||||
"eslint": "^7.30.0",
|
||||
"typescript": "^4.3.5"
|
||||
"@redhat-actions/action-io-generator": "1.5.0",
|
||||
"@redhat-actions/eslint-config": "1.3.2",
|
||||
"@redhat-actions/tsconfig": "1.2.0",
|
||||
"@types/ini": "1.3.31",
|
||||
"@types/node": "^20.0",
|
||||
"@typescript-eslint/eslint-plugin": "6.7.3",
|
||||
"@typescript-eslint/parser": "6.7.3",
|
||||
"@vercel/ncc": "0.38.0",
|
||||
"eslint": "8.50.0",
|
||||
"typescript": "5.2.2"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -66,9 +66,17 @@ export class BuildahCli implements Buildah {
|
|||
}
|
||||
|
||||
async buildUsingDocker(
|
||||
image: string, context: string, containerFiles: string[], buildArgs: string[],
|
||||
useOCI: boolean, labels: string[], layers: string,
|
||||
extraArgs: string[], tlsVerify: boolean, arch?: string, platform?: string
|
||||
image: string,
|
||||
context: string,
|
||||
containerFiles: string[],
|
||||
buildArgs: string[],
|
||||
useOCI: boolean,
|
||||
labels: string[],
|
||||
layers: string,
|
||||
extraArgs: string[],
|
||||
tlsVerify: boolean,
|
||||
arch?: string,
|
||||
platform?: string
|
||||
): Promise<CommandResult> {
|
||||
const args: string[] = [ "bud" ];
|
||||
if (arch) {
|
||||
|
@ -122,8 +130,9 @@ export class BuildahCli implements Buildah {
|
|||
|
||||
core.debug("copy");
|
||||
core.debug(container);
|
||||
for (const content of contentToCopy) {
|
||||
const args: string[] = [ "copy", container, content ];
|
||||
core.debug("content: " + contentToCopy.join(" "));
|
||||
if (contentToCopy.length > 0) {
|
||||
const args: string[] = [ "copy", container ].concat(contentToCopy);
|
||||
if (contentPath) {
|
||||
args.push(contentPath);
|
||||
}
|
||||
|
@ -192,6 +201,26 @@ export class BuildahCli implements Buildah {
|
|||
core.info(`✅ Successfully built image${builtImage.length !== 1 ? "s" : ""} "${builtImage.join(", ")}"`);
|
||||
}
|
||||
|
||||
// Unfortunately buildah doesn't support the exists command yet
|
||||
// https://github.com/containers/buildah/issues/4217
|
||||
|
||||
// async manifestExists(manifest: string): Promise<boolean> {
|
||||
// const args: string[] = [ "manifest", "exists" ];
|
||||
// args.push(manifest);
|
||||
// const execOptions: exec.ExecOptions = {ignoreReturnCode: true};
|
||||
// core.info(`Checking if manifest ${manifest} exists`);
|
||||
// const {exitCode} = await this.execute(args, execOptions);
|
||||
// return exitCode ? false : true;
|
||||
// }
|
||||
|
||||
async manifestRm(manifest: string): Promise<void> {
|
||||
const execOptions: exec.ExecOptions = { ignoreReturnCode: true };
|
||||
const args: string[] = [ "manifest", "rm" ];
|
||||
args.push(manifest);
|
||||
core.info(`Removing existing manifest ${manifest}`);
|
||||
await this.execute(args, execOptions);
|
||||
}
|
||||
|
||||
async manifestCreate(manifest: string): Promise<void> {
|
||||
const args: string[] = [ "manifest", "create" ];
|
||||
args.push(manifest);
|
||||
|
|
82
src/index.ts
82
src/index.ts
|
@ -87,8 +87,17 @@ export async function run(): Promise<void> {
|
|||
|
||||
const builtImage = [];
|
||||
if (containerFiles.length !== 0) {
|
||||
builtImage.push(...await doBuildUsingContainerFiles(cli, newImage, workspace, containerFiles, useOCI,
|
||||
archs, platforms, labelsList, buildahExtraArgs));
|
||||
builtImage.push(...await doBuildUsingContainerFiles(
|
||||
cli,
|
||||
newImage,
|
||||
workspace,
|
||||
containerFiles,
|
||||
useOCI,
|
||||
archs,
|
||||
platforms,
|
||||
labelsList,
|
||||
buildahExtraArgs
|
||||
));
|
||||
}
|
||||
else {
|
||||
if (platforms.length > 0) {
|
||||
|
@ -103,6 +112,8 @@ export async function run(): Promise<void> {
|
|||
const builtManifest = [];
|
||||
for (const tag of normalizedTagsList) {
|
||||
const manifestName = getFullImageName(normalizedImage, tag);
|
||||
// Force-remove existing manifest to prevent errors on recurring build on the same machine
|
||||
await cli.manifestRm(manifestName);
|
||||
await cli.manifestCreate(manifestName);
|
||||
builtManifest.push(manifestName);
|
||||
|
||||
|
@ -133,8 +144,15 @@ export async function run(): Promise<void> {
|
|||
}
|
||||
|
||||
async function doBuildUsingContainerFiles(
|
||||
cli: BuildahCli, newImage: string, workspace: string, containerFiles: string[], useOCI: boolean, archs: string[],
|
||||
platforms: string[], labels: string[], extraArgs: string[]
|
||||
cli: BuildahCli,
|
||||
newImage: string,
|
||||
workspace: string,
|
||||
containerFiles: string[],
|
||||
useOCI: boolean,
|
||||
archs: string[],
|
||||
platforms: string[],
|
||||
labels: string[],
|
||||
extraArgs: string[]
|
||||
): Promise<string[]> {
|
||||
if (containerFiles.length === 1) {
|
||||
core.info(`Performing build from Containerfile`);
|
||||
|
@ -161,8 +179,16 @@ async function doBuildUsingContainerFiles(
|
|||
tagSuffix = `-${removeIllegalCharacters(arch)}`;
|
||||
}
|
||||
await cli.buildUsingDocker(
|
||||
`${newImage}${tagSuffix}`, context, containerFileAbsPaths, buildArgs,
|
||||
useOCI, labels, layers, extraArgs, tlsVerify, arch, undefined
|
||||
`${newImage}${tagSuffix}`,
|
||||
context,
|
||||
containerFileAbsPaths,
|
||||
buildArgs,
|
||||
useOCI,
|
||||
labels,
|
||||
layers,
|
||||
extraArgs,
|
||||
tlsVerify,
|
||||
arch
|
||||
);
|
||||
builtImage.push(`${newImage}${tagSuffix}`);
|
||||
}
|
||||
|
@ -173,8 +199,17 @@ async function doBuildUsingContainerFiles(
|
|||
tagSuffix = `-${removeIllegalCharacters(platform)}`;
|
||||
}
|
||||
await cli.buildUsingDocker(
|
||||
`${newImage}${tagSuffix}`, context, containerFileAbsPaths, buildArgs,
|
||||
useOCI, labels, layers, extraArgs, tlsVerify, undefined, platform
|
||||
`${newImage}${tagSuffix}`,
|
||||
context,
|
||||
containerFileAbsPaths,
|
||||
buildArgs,
|
||||
useOCI,
|
||||
labels,
|
||||
layers,
|
||||
extraArgs,
|
||||
tlsVerify,
|
||||
undefined,
|
||||
platform
|
||||
);
|
||||
builtImage.push(`${newImage}${tagSuffix}`);
|
||||
}
|
||||
|
@ -182,15 +217,31 @@ async function doBuildUsingContainerFiles(
|
|||
|
||||
else if (archs.length === 1 || platforms.length === 1) {
|
||||
await cli.buildUsingDocker(
|
||||
newImage, context, containerFileAbsPaths, buildArgs,
|
||||
useOCI, labels, layers, extraArgs, tlsVerify, archs[0], platforms[0]
|
||||
newImage,
|
||||
context,
|
||||
containerFileAbsPaths,
|
||||
buildArgs,
|
||||
useOCI,
|
||||
labels,
|
||||
layers,
|
||||
extraArgs,
|
||||
tlsVerify,
|
||||
archs[0],
|
||||
platforms[0]
|
||||
);
|
||||
builtImage.push(newImage);
|
||||
}
|
||||
else {
|
||||
await cli.buildUsingDocker(
|
||||
newImage, context, containerFileAbsPaths, buildArgs,
|
||||
useOCI, labels, layers, extraArgs, tlsVerify
|
||||
newImage,
|
||||
context,
|
||||
containerFileAbsPaths,
|
||||
buildArgs,
|
||||
useOCI,
|
||||
labels,
|
||||
layers,
|
||||
extraArgs,
|
||||
tlsVerify
|
||||
);
|
||||
builtImage.push(newImage);
|
||||
}
|
||||
|
@ -199,7 +250,12 @@ async function doBuildUsingContainerFiles(
|
|||
}
|
||||
|
||||
async function doBuildFromScratch(
|
||||
cli: BuildahCli, newImage: string, useOCI: boolean, archs: string[], labels: string[], extraArgs: string[]
|
||||
cli: BuildahCli,
|
||||
newImage: string,
|
||||
useOCI: boolean,
|
||||
archs: string[],
|
||||
labels: string[],
|
||||
extraArgs: string[]
|
||||
): Promise<string[]> {
|
||||
core.info(`Performing build from scratch`);
|
||||
|
||||
|
|
|
@ -55,7 +55,9 @@ export async function findFuseOverlayfsPath(): Promise<string | undefined> {
|
|||
fuseOverlayfsPath = await io.which("fuse-overlayfs");
|
||||
}
|
||||
catch (err) {
|
||||
core.debug(err);
|
||||
if (err instanceof Error) {
|
||||
core.debug(err.message);
|
||||
}
|
||||
}
|
||||
|
||||
return fuseOverlayfsPath;
|
||||
|
|
Loading…
Reference in a new issue