mirror of
https://github.com/redhat-actions/push-to-registry.git
synced 2025-04-20 15:21:23 +00:00
Resolve Review comments
Signed-off-by: divyansh42 <diagrawa@redhat.com>
This commit is contained in:
parent
4deaffac48
commit
34d200b35d
13 changed files with 332 additions and 136 deletions
|
@ -1,6 +1,6 @@
|
|||
// eslint-disable-next-line no-undef
|
||||
module.exports = {
|
||||
extends: [
|
||||
"@tetchel/eslint-config-actions",
|
||||
"@redhat-actions/eslint-config",
|
||||
],
|
||||
};
|
||||
|
|
48
.github/workflows/verify-push-test1.yaml
vendored
Normal file
48
.github/workflows/verify-push-test1.yaml
vendored
Normal file
|
@ -0,0 +1,48 @@
|
|||
# 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: Test Push with Podman newer
|
||||
on: [ push, workflow_dispatch ]
|
||||
env:
|
||||
IMAGE_NAME: myimage
|
||||
IMAGE_REGISTRY: quay.io
|
||||
IMAGE_TAG: latest
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: Push image to Quay.io
|
||||
runs-on: ubuntu-20.04
|
||||
steps:
|
||||
# Checkout push-to-registry action github repository
|
||||
- name: Checkout Push to Registry action
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Build Image using Docker
|
||||
run: |
|
||||
docker build -t ${{ env.IMAGE_NAME }}:latest -<<EOF
|
||||
FROM busybox
|
||||
RUN echo "hello world"
|
||||
EOF
|
||||
|
||||
- name: Build Image using Podman
|
||||
run: |
|
||||
podman build -t ${{ env.IMAGE_NAME }}:latest -<<EOF
|
||||
FROM busybox
|
||||
RUN echo "hello world"
|
||||
EOF
|
||||
|
||||
# Push the image to image registry
|
||||
- name: Push To Quay
|
||||
uses: ./
|
||||
id: push
|
||||
with:
|
||||
image: ${{ env.IMAGE_NAME }}
|
||||
tag: ${{ env.IMAGE_TAG }}
|
||||
registry: ${{ env.IMAGE_REGISTRY }}/${{ secrets.REGISTRY_USER }}
|
||||
username: ${{ secrets.REGISTRY_USER }}
|
||||
password: ${{ secrets.REGISTRY_PASSWORD }}
|
||||
|
||||
- name: Echo outputs
|
||||
run: |
|
||||
echo "registry-path ${{ steps.push.outputs.registry-path }}"
|
||||
echo "digest ${{ steps.push.outputs.digest }}"
|
48
.github/workflows/verify-push-test2.yaml
vendored
Normal file
48
.github/workflows/verify-push-test2.yaml
vendored
Normal file
|
@ -0,0 +1,48 @@
|
|||
# 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: Test Push with docker newer
|
||||
on: [ push, workflow_dispatch ]
|
||||
env:
|
||||
IMAGE_NAME: myimage
|
||||
IMAGE_REGISTRY: quay.io
|
||||
IMAGE_TAG: latest
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: Push image to Quay.io
|
||||
runs-on: ubuntu-20.04
|
||||
steps:
|
||||
# Checkout push-to-registry action github repository
|
||||
- name: Checkout Push to Registry action
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Build Image using Podman
|
||||
run: |
|
||||
podman build -t ${{ env.IMAGE_NAME }}:latest -<<EOF
|
||||
FROM busybox
|
||||
RUN echo "hello world"
|
||||
EOF
|
||||
|
||||
- name: Build Image using Docker
|
||||
run: |
|
||||
docker build -t ${{ env.IMAGE_NAME }}:latest -<<EOF
|
||||
FROM busybox
|
||||
RUN echo "hello world"
|
||||
EOF
|
||||
|
||||
# Push the image to image registry
|
||||
- name: Push To Quay
|
||||
uses: ./
|
||||
id: push
|
||||
with:
|
||||
image: ${{ env.IMAGE_NAME }}
|
||||
tag: ${{ env.IMAGE_TAG }}
|
||||
registry: ${{ env.IMAGE_REGISTRY }}/${{ secrets.REGISTRY_USER }}
|
||||
username: ${{ secrets.REGISTRY_USER }}
|
||||
password: ${{ secrets.REGISTRY_PASSWORD }}
|
||||
|
||||
- name: Echo outputs
|
||||
run: |
|
||||
echo "registry-path ${{ steps.push.outputs.registry-path }}"
|
||||
echo "digest ${{ steps.push.outputs.digest }}"
|
41
.github/workflows/verify-push-test3.yaml
vendored
Normal file
41
.github/workflows/verify-push-test3.yaml
vendored
Normal file
|
@ -0,0 +1,41 @@
|
|||
# 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: Test Push with only Podman
|
||||
on: [ push, workflow_dispatch ]
|
||||
env:
|
||||
IMAGE_NAME: myimage
|
||||
IMAGE_REGISTRY: quay.io
|
||||
IMAGE_TAG: latest
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: Push image to Quay.io
|
||||
runs-on: ubuntu-20.04
|
||||
steps:
|
||||
# Checkout push-to-registry action github repository
|
||||
- name: Checkout Push to Registry action
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Build Image using Podman
|
||||
run: |
|
||||
podman build -t ${{ env.IMAGE_NAME }}:latest -<<EOF
|
||||
FROM busybox
|
||||
RUN echo "hello world"
|
||||
EOF
|
||||
|
||||
# Push the image to image registry
|
||||
- name: Push To Quay
|
||||
uses: ./
|
||||
id: push
|
||||
with:
|
||||
image: ${{ env.IMAGE_NAME }}
|
||||
tag: ${{ env.IMAGE_TAG }}
|
||||
registry: ${{ env.IMAGE_REGISTRY }}/${{ secrets.REGISTRY_USER }}
|
||||
username: ${{ secrets.REGISTRY_USER }}
|
||||
password: ${{ secrets.REGISTRY_PASSWORD }}
|
||||
|
||||
- name: Echo outputs
|
||||
run: |
|
||||
echo "registry-path ${{ steps.push.outputs.registry-path }}"
|
||||
echo "digest ${{ steps.push.outputs.digest }}"
|
41
.github/workflows/verify-push-test4.yaml
vendored
Normal file
41
.github/workflows/verify-push-test4.yaml
vendored
Normal file
|
@ -0,0 +1,41 @@
|
|||
# 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: Test Push with only Docker
|
||||
on: [ push, workflow_dispatch ]
|
||||
env:
|
||||
IMAGE_NAME: myimage
|
||||
IMAGE_REGISTRY: quay.io
|
||||
IMAGE_TAG: latest
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: Push image to Quay.io
|
||||
runs-on: ubuntu-20.04
|
||||
steps:
|
||||
# Checkout push-to-registry action github repository
|
||||
- name: Checkout Push to Registry action
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Build Image using Docker
|
||||
run: |
|
||||
docker build -t ${{ env.IMAGE_NAME }}:latest -<<EOF
|
||||
FROM busybox
|
||||
RUN echo "hello world"
|
||||
EOF
|
||||
|
||||
# Push the image to image registry
|
||||
- name: Push To Quay
|
||||
uses: ./
|
||||
id: push
|
||||
with:
|
||||
image: ${{ env.IMAGE_NAME }}
|
||||
tag: ${{ env.IMAGE_TAG }}
|
||||
registry: ${{ env.IMAGE_REGISTRY }}/${{ secrets.REGISTRY_USER }}
|
||||
username: ${{ secrets.REGISTRY_USER }}
|
||||
password: ${{ secrets.REGISTRY_PASSWORD }}
|
||||
|
||||
- name: Echo outputs
|
||||
run: |
|
||||
echo "registry-path ${{ steps.push.outputs.registry-path }}"
|
||||
echo "digest ${{ steps.push.outputs.digest }}"
|
16
.github/workflows/verify-push.yaml
vendored
16
.github/workflows/verify-push.yaml
vendored
|
@ -1,8 +1,8 @@
|
|||
# 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: Test Push
|
||||
on: [push, pull_request, workflow_dispatch]
|
||||
name: Test Push without image
|
||||
on: [ push, workflow_dispatch ]
|
||||
env:
|
||||
IMAGE_NAME: myimage
|
||||
IMAGE_REGISTRY: quay.io
|
||||
|
@ -17,12 +17,12 @@ jobs:
|
|||
- name: Checkout Push to Registry action
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Build Image using Docker
|
||||
run: |
|
||||
docker build -t ${{ env.IMAGE_NAME }}:latest -<<EOF
|
||||
FROM busybox
|
||||
RUN echo "hello world"
|
||||
EOF
|
||||
# - name: Build Image using Docker
|
||||
# run: |
|
||||
# docker build -t ${{ env.IMAGE_NAME }}:latest -<<EOF
|
||||
# FROM busybox
|
||||
# RUN echo "hello world"
|
||||
# EOF
|
||||
|
||||
# Push the image to image registry
|
||||
- name: Push To Quay
|
||||
|
|
|
@ -120,6 +120,11 @@ jobs:
|
|||
run: echo "New image has been pushed to ${{ steps.push-to-quay.outputs.registry-path }}"
|
||||
```
|
||||
|
||||
**NOTE**:
|
||||
- This action use `Docker` and `Podman` both as the command line tools. Docker and Podman stores image in their respective local image storage's.
|
||||
- If image is present in Docker image storage then image will be pulled into Podman's image storage and will be removed once image is pushed to the desired image registry.
|
||||
- In case image with same name and same version is present in Docker as well as Podman image storage, then this action will push the latest built version amongst the Docker and Podman image storage's.
|
||||
|
||||
## Troubleshooting
|
||||
Note that quay.io repositories are private by default.<br>
|
||||
|
||||
|
|
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
124
package-lock.json
generated
124
package-lock.json
generated
|
@ -62,9 +62,9 @@
|
|||
}
|
||||
},
|
||||
"@eslint/eslintrc": {
|
||||
"version": "0.2.2",
|
||||
"resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-0.2.2.tgz",
|
||||
"integrity": "sha512-EfB5OHNYp1F4px/LI/FEnGylop7nOqkQ1LRzCM0KccA2U8tvV8w01KBv37LbO7nW4H+YhKyo2LcJhRwjjV17QQ==",
|
||||
"version": "0.3.0",
|
||||
"resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-0.3.0.tgz",
|
||||
"integrity": "sha512-1JTKgrOKAHVivSvOYw+sJOunkBjUOvjqWk1DPja7ZFhIS2mX/4EgTT8M7eTK9jrKhL/FvXXEbQwIs3pg1xp3dg==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"ajv": "^6.12.4",
|
||||
|
@ -74,7 +74,7 @@
|
|||
"ignore": "^4.0.6",
|
||||
"import-fresh": "^3.2.1",
|
||||
"js-yaml": "^3.13.1",
|
||||
"lodash": "^4.17.19",
|
||||
"lodash": "^4.17.20",
|
||||
"minimatch": "^3.0.4",
|
||||
"strip-json-comments": "^3.1.1"
|
||||
},
|
||||
|
@ -113,16 +113,22 @@
|
|||
"fastq": "^1.6.0"
|
||||
}
|
||||
},
|
||||
"@tetchel/eslint-config-actions": {
|
||||
"version": "0.0.8",
|
||||
"resolved": "https://registry.npmjs.org/@tetchel/eslint-config-actions/-/eslint-config-actions-0.0.8.tgz",
|
||||
"integrity": "sha512-DfR4CZ3wkkspIAf2DDgDoH1yN6zdiJ0NVVDlS5TziQgzDxydDGgjnQUxqB6YIqYEfw1NCL5eycZnscmbE3gvXQ==",
|
||||
"@redhat-actions/eslint-config": {
|
||||
"version": "1.2.0",
|
||||
"resolved": "https://registry.npmjs.org/@redhat-actions/eslint-config/-/eslint-config-1.2.0.tgz",
|
||||
"integrity": "sha512-HFpdgXIB01wmZbCsEpaY0UhQlRBiM/kJxO0WCufIx/wTxepewwsLTsgCgKkljbGfSaqN7FMJ/TbwY1CY/ltHcw==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"eslint-config-airbnb-base": ">= 14",
|
||||
"eslint-plugin-import": ">=2"
|
||||
}
|
||||
},
|
||||
"@redhat-actions/tsconfig": {
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/@redhat-actions/tsconfig/-/tsconfig-1.1.0.tgz",
|
||||
"integrity": "sha512-9eiU6lLepYIO/h51F8bph2KI4/ZdqK0inDcoOtaBGfQslsoSRygaTmRwD6EaejcDTor/5MZZo9dIKmm+5BGkXw==",
|
||||
"dev": true
|
||||
},
|
||||
"@types/json-schema": {
|
||||
"version": "7.0.6",
|
||||
"resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.6.tgz",
|
||||
|
@ -142,13 +148,13 @@
|
|||
"dev": true
|
||||
},
|
||||
"@typescript-eslint/eslint-plugin": {
|
||||
"version": "4.13.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-4.13.0.tgz",
|
||||
"integrity": "sha512-ygqDUm+BUPvrr0jrXqoteMqmIaZ/bixYOc3A4BRwzEPTZPi6E+n44rzNZWaB0YvtukgP+aoj0i/fyx7FkM2p1w==",
|
||||
"version": "4.14.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-4.14.0.tgz",
|
||||
"integrity": "sha512-IJ5e2W7uFNfg4qh9eHkHRUCbgZ8VKtGwD07kannJvM5t/GU8P8+24NX8gi3Hf5jST5oWPY8kyV1s/WtfiZ4+Ww==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@typescript-eslint/experimental-utils": "4.13.0",
|
||||
"@typescript-eslint/scope-manager": "4.13.0",
|
||||
"@typescript-eslint/experimental-utils": "4.14.0",
|
||||
"@typescript-eslint/scope-manager": "4.14.0",
|
||||
"debug": "^4.1.1",
|
||||
"functional-red-black-tree": "^1.0.1",
|
||||
"lodash": "^4.17.15",
|
||||
|
@ -158,55 +164,55 @@
|
|||
}
|
||||
},
|
||||
"@typescript-eslint/experimental-utils": {
|
||||
"version": "4.13.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/experimental-utils/-/experimental-utils-4.13.0.tgz",
|
||||
"integrity": "sha512-/ZsuWmqagOzNkx30VWYV3MNB/Re/CGv/7EzlqZo5RegBN8tMuPaBgNK6vPBCQA8tcYrbsrTdbx3ixMRRKEEGVw==",
|
||||
"version": "4.14.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/experimental-utils/-/experimental-utils-4.14.0.tgz",
|
||||
"integrity": "sha512-6i6eAoiPlXMKRbXzvoQD5Yn9L7k9ezzGRvzC/x1V3650rUk3c3AOjQyGYyF9BDxQQDK2ElmKOZRD0CbtdkMzQQ==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@types/json-schema": "^7.0.3",
|
||||
"@typescript-eslint/scope-manager": "4.13.0",
|
||||
"@typescript-eslint/types": "4.13.0",
|
||||
"@typescript-eslint/typescript-estree": "4.13.0",
|
||||
"@typescript-eslint/scope-manager": "4.14.0",
|
||||
"@typescript-eslint/types": "4.14.0",
|
||||
"@typescript-eslint/typescript-estree": "4.14.0",
|
||||
"eslint-scope": "^5.0.0",
|
||||
"eslint-utils": "^2.0.0"
|
||||
}
|
||||
},
|
||||
"@typescript-eslint/parser": {
|
||||
"version": "4.13.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-4.13.0.tgz",
|
||||
"integrity": "sha512-KO0J5SRF08pMXzq9+abyHnaGQgUJZ3Z3ax+pmqz9vl81JxmTTOUfQmq7/4awVfq09b6C4owNlOgOwp61pYRBSg==",
|
||||
"version": "4.14.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-4.14.0.tgz",
|
||||
"integrity": "sha512-sUDeuCjBU+ZF3Lzw0hphTyScmDDJ5QVkyE21pRoBo8iDl7WBtVFS+WDN3blY1CH3SBt7EmYCw6wfmJjF0l/uYg==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@typescript-eslint/scope-manager": "4.13.0",
|
||||
"@typescript-eslint/types": "4.13.0",
|
||||
"@typescript-eslint/typescript-estree": "4.13.0",
|
||||
"@typescript-eslint/scope-manager": "4.14.0",
|
||||
"@typescript-eslint/types": "4.14.0",
|
||||
"@typescript-eslint/typescript-estree": "4.14.0",
|
||||
"debug": "^4.1.1"
|
||||
}
|
||||
},
|
||||
"@typescript-eslint/scope-manager": {
|
||||
"version": "4.13.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-4.13.0.tgz",
|
||||
"integrity": "sha512-UpK7YLG2JlTp/9G4CHe7GxOwd93RBf3aHO5L+pfjIrhtBvZjHKbMhBXTIQNkbz7HZ9XOe++yKrXutYm5KmjWgQ==",
|
||||
"version": "4.14.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-4.14.0.tgz",
|
||||
"integrity": "sha512-/J+LlRMdbPh4RdL4hfP1eCwHN5bAhFAGOTsvE6SxsrM/47XQiPSgF5MDgLyp/i9kbZV9Lx80DW0OpPkzL+uf8Q==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@typescript-eslint/types": "4.13.0",
|
||||
"@typescript-eslint/visitor-keys": "4.13.0"
|
||||
"@typescript-eslint/types": "4.14.0",
|
||||
"@typescript-eslint/visitor-keys": "4.14.0"
|
||||
}
|
||||
},
|
||||
"@typescript-eslint/types": {
|
||||
"version": "4.13.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-4.13.0.tgz",
|
||||
"integrity": "sha512-/+aPaq163oX+ObOG00M0t9tKkOgdv9lq0IQv/y4SqGkAXmhFmCfgsELV7kOCTb2vVU5VOmVwXBXJTDr353C1rQ==",
|
||||
"version": "4.14.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-4.14.0.tgz",
|
||||
"integrity": "sha512-VsQE4VvpldHrTFuVPY1ZnHn/Txw6cZGjL48e+iBxTi2ksa9DmebKjAeFmTVAYoSkTk7gjA7UqJ7pIsyifTsI4A==",
|
||||
"dev": true
|
||||
},
|
||||
"@typescript-eslint/typescript-estree": {
|
||||
"version": "4.13.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-4.13.0.tgz",
|
||||
"integrity": "sha512-9A0/DFZZLlGXn5XA349dWQFwPZxcyYyCFX5X88nWs2uachRDwGeyPz46oTsm9ZJE66EALvEns1lvBwa4d9QxMg==",
|
||||
"version": "4.14.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-4.14.0.tgz",
|
||||
"integrity": "sha512-wRjZ5qLao+bvS2F7pX4qi2oLcOONIB+ru8RGBieDptq/SudYwshveORwCVU4/yMAd4GK7Fsf8Uq1tjV838erag==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@typescript-eslint/types": "4.13.0",
|
||||
"@typescript-eslint/visitor-keys": "4.13.0",
|
||||
"@typescript-eslint/types": "4.14.0",
|
||||
"@typescript-eslint/visitor-keys": "4.14.0",
|
||||
"debug": "^4.1.1",
|
||||
"globby": "^11.0.1",
|
||||
"is-glob": "^4.0.1",
|
||||
|
@ -216,12 +222,12 @@
|
|||
}
|
||||
},
|
||||
"@typescript-eslint/visitor-keys": {
|
||||
"version": "4.13.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-4.13.0.tgz",
|
||||
"integrity": "sha512-6RoxWK05PAibukE7jElqAtNMq+RWZyqJ6Q/GdIxaiUj2Ept8jh8+FUVlbq9WxMYxkmEOPvCE5cRSyupMpwW31g==",
|
||||
"version": "4.14.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-4.14.0.tgz",
|
||||
"integrity": "sha512-MeHHzUyRI50DuiPgV9+LxcM52FCJFYjJiWHtXlbyC27b80mfOwKeiKI+MHOTEpcpfmoPFm/vvQS88bYIx6PZTA==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@typescript-eslint/types": "4.13.0",
|
||||
"@typescript-eslint/types": "4.14.0",
|
||||
"eslint-visitor-keys": "^2.0.0"
|
||||
}
|
||||
},
|
||||
|
@ -524,23 +530,25 @@
|
|||
}
|
||||
},
|
||||
"es-abstract": {
|
||||
"version": "1.18.0-next.1",
|
||||
"resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.18.0-next.1.tgz",
|
||||
"integrity": "sha512-I4UGspA0wpZXWENrdA0uHbnhte683t3qT/1VFH9aX2dA5PPSf6QW5HHXf5HImaqPmjXaVeVk4RGWnaylmV7uAA==",
|
||||
"version": "1.18.0-next.2",
|
||||
"resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.18.0-next.2.tgz",
|
||||
"integrity": "sha512-Ih4ZMFHEtZupnUh6497zEL4y2+w8+1ljnCyaTa+adcoafI1GOvMwFlDjBLfWR7y9VLfrjRJe9ocuHY1PSR9jjw==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"call-bind": "^1.0.2",
|
||||
"es-to-primitive": "^1.2.1",
|
||||
"function-bind": "^1.1.1",
|
||||
"get-intrinsic": "^1.0.2",
|
||||
"has": "^1.0.3",
|
||||
"has-symbols": "^1.0.1",
|
||||
"is-callable": "^1.2.2",
|
||||
"is-negative-zero": "^2.0.0",
|
||||
"is-negative-zero": "^2.0.1",
|
||||
"is-regex": "^1.1.1",
|
||||
"object-inspect": "^1.8.0",
|
||||
"object-inspect": "^1.9.0",
|
||||
"object-keys": "^1.1.1",
|
||||
"object.assign": "^4.1.1",
|
||||
"string.prototype.trimend": "^1.0.1",
|
||||
"string.prototype.trimstart": "^1.0.1"
|
||||
"object.assign": "^4.1.2",
|
||||
"string.prototype.trimend": "^1.0.3",
|
||||
"string.prototype.trimstart": "^1.0.3"
|
||||
}
|
||||
},
|
||||
"es-to-primitive": {
|
||||
|
@ -561,13 +569,13 @@
|
|||
"dev": true
|
||||
},
|
||||
"eslint": {
|
||||
"version": "7.17.0",
|
||||
"resolved": "https://registry.npmjs.org/eslint/-/eslint-7.17.0.tgz",
|
||||
"integrity": "sha512-zJk08MiBgwuGoxes5sSQhOtibZ75pz0J35XTRlZOk9xMffhpA9BTbQZxoXZzOl5zMbleShbGwtw+1kGferfFwQ==",
|
||||
"version": "7.18.0",
|
||||
"resolved": "https://registry.npmjs.org/eslint/-/eslint-7.18.0.tgz",
|
||||
"integrity": "sha512-fbgTiE8BfUJZuBeq2Yi7J3RB3WGUQ9PNuNbmgi6jt9Iv8qrkxfy19Ds3OpL1Pm7zg3BtTVhvcUZbIRQ0wmSjAQ==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@babel/code-frame": "^7.0.0",
|
||||
"@eslint/eslintrc": "^0.2.2",
|
||||
"@eslint/eslintrc": "^0.3.0",
|
||||
"ajv": "^6.10.0",
|
||||
"chalk": "^4.0.0",
|
||||
"cross-spawn": "^7.0.2",
|
||||
|
@ -591,7 +599,7 @@
|
|||
"js-yaml": "^3.13.1",
|
||||
"json-stable-stringify-without-jsonify": "^1.0.1",
|
||||
"levn": "^0.4.1",
|
||||
"lodash": "^4.17.19",
|
||||
"lodash": "^4.17.20",
|
||||
"minimatch": "^3.0.4",
|
||||
"natural-compare": "^1.4.0",
|
||||
"optionator": "^0.9.1",
|
||||
|
@ -837,9 +845,9 @@
|
|||
"dev": true
|
||||
},
|
||||
"fast-glob": {
|
||||
"version": "3.2.4",
|
||||
"resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.2.4.tgz",
|
||||
"integrity": "sha512-kr/Oo6PX51265qeuCYsyGypiO5uJFgBS0jksyG7FUeCyQzNwYnzrNIMR1NXfkZXsMYXYLRAHgISHBz8gQcxKHQ==",
|
||||
"version": "3.2.5",
|
||||
"resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.2.5.tgz",
|
||||
"integrity": "sha512-2DtFcgT68wiTTiwZ2hNdJfcHNke9XOfnwmBRWXhmeKM8rF0TGwmC/Qto3S7RoZKp5cilZbxzO5iTNTQsJ+EeDg==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@nodelib/fs.stat": "^2.0.2",
|
||||
|
|
|
@ -18,12 +18,13 @@
|
|||
"@actions/io": "^1.0.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@tetchel/eslint-config-actions": "0.0.8",
|
||||
"@redhat-actions/eslint-config": "^1.2.0",
|
||||
"@redhat-actions/tsconfig": "^1.1.0",
|
||||
"@types/node": "^12.12.7",
|
||||
"@typescript-eslint/eslint-plugin": "^4.13.0",
|
||||
"@typescript-eslint/parser": "^4.13.0",
|
||||
"@typescript-eslint/eslint-plugin": "^4.14.0",
|
||||
"@typescript-eslint/parser": "^4.14.0",
|
||||
"@vercel/ncc": "^0.25.1",
|
||||
"eslint": "^7.17.0",
|
||||
"eslint": "^7.18.0",
|
||||
"typescript": "^4.0.5"
|
||||
}
|
||||
}
|
||||
|
|
111
src/index.ts
111
src/index.ts
|
@ -4,12 +4,25 @@ import * as io from "@actions/io";
|
|||
import * as fs from "fs";
|
||||
import * as path from "path";
|
||||
|
||||
interface Response {
|
||||
interface ExecResult {
|
||||
exitCode: number;
|
||||
stdout: string;
|
||||
stderr: string;
|
||||
}
|
||||
|
||||
let podmanPath: string | undefined;
|
||||
|
||||
async function getPodmanPath(): Promise<string> {
|
||||
if (podmanPath == null) {
|
||||
podmanPath = await io.which("podman", true);
|
||||
}
|
||||
|
||||
return podmanPath;
|
||||
}
|
||||
|
||||
// base URL that gets appended if image is pulled from the Docker imaege storage
|
||||
const dockerBaseUrl = "docker.io/library";
|
||||
|
||||
async function run(): Promise<void> {
|
||||
const imageInput = core.getInput("image", { required: true });
|
||||
const tag = core.getInput("tag") || "latest";
|
||||
|
@ -19,51 +32,43 @@ async function run(): Promise<void> {
|
|||
const tlsVerify = core.getInput("tls-verify");
|
||||
const digestFileInput = core.getInput("digestfile");
|
||||
|
||||
// get Podman cli
|
||||
const podman = await io.which("podman", true);
|
||||
|
||||
let imageToPush = `${imageInput}:${tag}`;
|
||||
|
||||
// check if image exist in Podman local registry
|
||||
// check if image exist in Podman image storage
|
||||
const isPresentInPodman: boolean = await checkImageInPodman(
|
||||
imageToPush,
|
||||
podman,
|
||||
);
|
||||
|
||||
// check if image exist in Docker local registry and if exist pull the image to Podman
|
||||
// check if image exist in Docker image storage and if exist pull the image to Podman
|
||||
const isPresentInDocker: boolean = await pullImageFromDocker(
|
||||
imageToPush,
|
||||
podman,
|
||||
);
|
||||
|
||||
// boolean value to check if pushed image is from Docker local registry
|
||||
// failing if image is not found in Docker as well as Podman
|
||||
if (!isPresentInDocker && !isPresentInPodman) {
|
||||
throw new Error(`Image ${imageToPush} not found in Podman local storage, or Docker local storage.`);
|
||||
}
|
||||
|
||||
// boolean value to check if pushed image is from Docker image storage
|
||||
let isPushingDockerImage = false;
|
||||
|
||||
if (isPresentInPodman && isPresentInDocker) {
|
||||
const warningMsg = "Image found in Podman as well as in Docker local registry.";
|
||||
|
||||
let isPodmanImageLatest = false;
|
||||
try {
|
||||
isPodmanImageLatest = await isPodmanLocalImageLatest(
|
||||
imageToPush,
|
||||
podman,
|
||||
);
|
||||
}
|
||||
catch (err) {
|
||||
core.setFailed(err);
|
||||
}
|
||||
const isPodmanImageLatest = await isPodmanLocalImageLatest(
|
||||
imageToPush,
|
||||
);
|
||||
|
||||
if (!isPodmanImageLatest) {
|
||||
core.warning(`${warningMsg} Using Docker local registry's image as that is built latest`);
|
||||
imageToPush = `docker.io/library/${imageToPush}`;
|
||||
core.warning(`The version of ${imageToPush} in the Docker image storage is more recent than the version in the Podman image storage. The image from the Docker image storage will be pushed.`);
|
||||
imageToPush = `${dockerBaseUrl}/${imageToPush}`;
|
||||
isPushingDockerImage = true;
|
||||
}
|
||||
else {
|
||||
core.warning(`${warningMsg} Using Podman local registry's image as that is built latest`);
|
||||
core.warning(`The version of ${imageToPush} in the Podman image storage is more recent than the version in the Docker image storage. The image from the Podman image storage will be pushed.`);
|
||||
}
|
||||
}
|
||||
else if (isPresentInDocker) {
|
||||
imageToPush = `docker.io/library/${imageToPush}`;
|
||||
imageToPush = `${dockerBaseUrl}/${imageToPush}`;
|
||||
core.info(`Image ${imageToPush} was found in the Docker image storage, but not in the Podman image storage. The image will be pulled into Podman image storage, pushed, and then removed from the Podman image storage.`);
|
||||
isPushingDockerImage = true;
|
||||
}
|
||||
|
||||
|
@ -73,7 +78,8 @@ async function run(): Promise<void> {
|
|||
}
|
||||
core.info(pushMsg);
|
||||
|
||||
const registryPath = `${registry.replace(/\/$/, "")}/${imageInput}:${tag}`;
|
||||
const registryWithoutTrailingSlash = registry.replace(/\/$/, "");
|
||||
const registryPath = `${registryWithoutTrailingSlash}/${imageInput}:${tag}`;
|
||||
|
||||
const creds = `${username}:${password}`;
|
||||
|
||||
|
@ -85,7 +91,7 @@ async function run(): Promise<void> {
|
|||
)}_digest.txt`;
|
||||
}
|
||||
|
||||
// push image
|
||||
// push the image
|
||||
const args = [
|
||||
"push",
|
||||
"--quiet",
|
||||
|
@ -102,15 +108,15 @@ async function run(): Promise<void> {
|
|||
args.push(`--tls-verify=${tlsVerify}`);
|
||||
}
|
||||
|
||||
await execute(podman, args);
|
||||
await execute(await getPodmanPath(), args);
|
||||
|
||||
core.info(`Successfully pushed ${imageToPush} to ${registryPath}.`);
|
||||
core.setOutput("registry-path", registryPath);
|
||||
|
||||
// remove the pulled image from the Podman local registry
|
||||
// remove the pulled image from the Podman image storage
|
||||
if (isPushingDockerImage) {
|
||||
core.info(`Removing ${imageToPush} from the Podman local registry`);
|
||||
await execute(podman, [ "rmi", imageToPush ]);
|
||||
core.info(`Removing ${imageToPush} from the Podman image storage`);
|
||||
await execute(await getPodmanPath(), [ "rmi", imageToPush ]);
|
||||
}
|
||||
|
||||
try {
|
||||
|
@ -125,43 +131,40 @@ async function run(): Promise<void> {
|
|||
|
||||
async function pullImageFromDocker(
|
||||
imageName: string,
|
||||
podman: string,
|
||||
): Promise<boolean> {
|
||||
try {
|
||||
await execute(podman, [ "pull", `docker-daemon:${imageName}` ]);
|
||||
core.info("Image found and sucessfully pulled from Docker local registry");
|
||||
await execute(await getPodmanPath(), [ "pull", `docker-daemon:${imageName}` ]);
|
||||
core.info(`Image ${imageName} found in Docker image storage`);
|
||||
return true;
|
||||
}
|
||||
catch (err) {
|
||||
core.info("Image not found in Docker local registry");
|
||||
core.info(`Image ${imageName} not found in Docker image storage`);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
async function checkImageInPodman(
|
||||
imageName: string,
|
||||
podman: string,
|
||||
): Promise<boolean> {
|
||||
// check if images exist in Podman's local registry
|
||||
core.info("Checking image in Podman local registry");
|
||||
// check if images exist in Podman's storage
|
||||
core.info("Checking image in Podman image storage");
|
||||
try {
|
||||
await execute(podman, [ "image", "exists", imageName ]);
|
||||
core.info("Image found in Podman local registry");
|
||||
await execute(await getPodmanPath(), [ "image", "exists", imageName ]);
|
||||
core.info(`Image ${imageName} found in Podman image storage`);
|
||||
return true;
|
||||
}
|
||||
catch (err) {
|
||||
core.info("Image not found in Podman local registry");
|
||||
core.info(`Image ${imageName} not found in Podman image storage`);
|
||||
core.debug(err);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
async function isPodmanLocalImageLatest(
|
||||
imageName: string,
|
||||
podman: string,
|
||||
): Promise<boolean> {
|
||||
// get creation time of the image present in the Podman local registry
|
||||
const podmanLocalImageTimeStamp = await execute(podman, [
|
||||
// get creation time of the image present in the Podman image storage
|
||||
const podmanLocalImageTimeStamp = await execute(await getPodmanPath(), [
|
||||
"image",
|
||||
"inspect",
|
||||
imageName,
|
||||
|
@ -169,17 +172,21 @@ async function isPodmanLocalImageLatest(
|
|||
"{{.Created}}",
|
||||
]);
|
||||
|
||||
// get creation time of the image pulled from the Docker local registry
|
||||
core.info(`The image from Podman image storage was last modified at ${podmanLocalImageTimeStamp.stdout}`);
|
||||
|
||||
// get creation time of the image pulled from the Docker image storage
|
||||
// appending 'docker.io/library' infront of image name as pulled image name
|
||||
// from Docker local registry starts with the 'docker.io/library'
|
||||
const pulledImageCreationTimeStamp = await execute(podman, [
|
||||
// from Docker image storage starts with the 'docker.io/library'
|
||||
const pulledImageCreationTimeStamp = await execute(await getPodmanPath(), [
|
||||
"image",
|
||||
"inspect",
|
||||
`docker.io/library/${imageName}`,
|
||||
`${dockerBaseUrl}/${imageName}`,
|
||||
"--format",
|
||||
"{{.Created}}",
|
||||
]);
|
||||
|
||||
core.info(`The image from Docker image storage was last modified at ${pulledImageCreationTimeStamp.stdout}`);
|
||||
|
||||
const podmanImageTime = new Date(podmanLocalImageTimeStamp.stdout).getTime();
|
||||
|
||||
const dockerImageTime = new Date(pulledImageCreationTimeStamp.stdout).getTime();
|
||||
|
@ -191,7 +198,7 @@ async function execute(
|
|||
executable: string,
|
||||
args: string[],
|
||||
execOptions: exec.ExecOptions = {},
|
||||
): Promise<Response> {
|
||||
): Promise<ExecResult> {
|
||||
let stdout = "";
|
||||
let stderr = "";
|
||||
|
||||
|
@ -199,10 +206,10 @@ async function execute(
|
|||
finalExecOptions.ignoreReturnCode = true; // the return code is processed below
|
||||
|
||||
finalExecOptions.listeners = {
|
||||
stdline: (line) => {
|
||||
stdline: (line): void => {
|
||||
stdout += `${line}\n`;
|
||||
},
|
||||
errline: (line) => {
|
||||
errline: (line): void => {
|
||||
stderr += `${line}\n`;
|
||||
},
|
||||
};
|
||||
|
|
|
@ -1,14 +1,11 @@
|
|||
{
|
||||
"extends": "@redhat-actions/tsconfig",
|
||||
"compilerOptions": {
|
||||
"target": "ES6",
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"ES2017"
|
||||
],
|
||||
"outDir": "out",
|
||||
"rootDir": ".",
|
||||
"rootDir": "src/",
|
||||
"outDir": "out/"
|
||||
},
|
||||
"exclude": [
|
||||
"node_modules"
|
||||
]
|
||||
}
|
||||
"include": [
|
||||
"src/"
|
||||
],
|
||||
}
|
||||
|
Loading…
Reference in a new issue