Resolve reviews

Signed-off-by: divyansh42 <diagrawa@redhat.com>
This commit is contained in:
divyansh42 2021-04-09 23:39:13 +05:30
parent 2c3fb7261b
commit eb5edfc198
6 changed files with 89 additions and 25 deletions

65
.github/workflows/verify-login-push.yml vendored Normal file
View file

@ -0,0 +1,65 @@
# 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: Login and Push
on:
push:
workflow_dispatch:
schedule:
- cron: '0 0 * * *' # every day at midnight
env:
IMAGE_NAME: myimage
IMAGE_REGISTRY: quay.io
IMAGE_TAGS: v1 ${{ github.sha }}
jobs:
login-and-push:
name: Login and 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: Create Dockerfile
run: |
cat > Dockerfile<<EOF
FROM busybox
RUN echo "hello world"
EOF
# Build image using Buildah action
- name: Build Image
id: build_image
uses: redhat-actions/buildah-build@v2
with:
image: ${{ env.IMAGE_NAME }}
layers: false
tags: ${{ env.IMAGE_TAGS }}
dockerfiles: |
./Dockerfile
# Authenticate to container image registry to push the image
- name: Podman Login
uses: redhat-actions/podman-login@v1
with:
registry: quay.io
username: ${{ secrets.REGISTRY_USER }}
password: ${{ secrets.REGISTRY_PASSWORD }}
# Push the image to Quay.io (Image Registry)
- name: Push To Quay
uses: ./
id: push
with:
image: ${{ steps.build_image.outputs.image }}
tags: ${{ steps.build_image.outputs.tags }}
registry: ${{ env.IMAGE_REGISTRY }}/${{ secrets.REGISTRY_USER }}
extra-args: |
--disable-content-trust
- name: Echo outputs
run: |
echo "${{ toJSON(steps.push.outputs) }}"

View file

@ -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: Test Build and Push
name: Build and Push
on:
push:
workflow_dispatch:
@ -86,16 +86,6 @@ jobs:
spring-petclinic-*.jar
port: 8080
oci: 'true'
env:
STORAGE_OPTS: "overlay.mount_program=/usr/bin/fuse-overlayfs"
# Authenticate to container image registry to push the image
- name: Podman Login
uses: redhat-actions/podman-login@v1
with:
registry: quay.io
username: ${{ secrets.REGISTRY_USER }}
password: ${{ secrets.REGISTRY_PASSWORD }}
# Push the image to Quay.io (Image Registry)
- name: Push To Quay
@ -105,6 +95,8 @@ jobs:
image: ${{ steps.build_image.outputs.image }}
tags: ${{ steps.build_image.outputs.tags }}
registry: ${{ env.IMAGE_REGISTRY }}/${{ secrets.REGISTRY_USER }}
username: ${{ secrets.REGISTRY_USER }}
password: ${{ secrets.REGISTRY_PASSWORD }}
extra-args: |
--disable-content-trust

View file

@ -1,7 +1,8 @@
# push-to-registry
[![CI checks](https://github.com/redhat-actions/push-to-registry/workflows/CI%20checks/badge.svg)](https://github.com/redhat-actions/push-to-registry/actions?query=workflow%3A%22CI+checks%22)
[![Test Build and Push](https://github.com/redhat-actions/push-to-registry/workflows/Test%20Build%20and%20Push/badge.svg)](https://github.com/redhat-actions/push-to-registry/actions?query=workflow%3A%22Test+Build+and+Push%22)
[![Build and Push](https://github.com/redhat-actions/push-to-registry/workflows/Build%20and%20Push/badge.svg)](https://github.com/redhat-actions/push-to-registry/actions?query=workflow%3A%22Build+and+Push%22)
[![Login and Push](https://github.com/redhat-actions/push-to-registry/workflows/Login%20and%20Push/badge.svg)](https://github.com/redhat-actions/push-to-registry/actions?query=workflow%3A%22Login+and+Push%22)
[![Multiple container CLI build tests](https://github.com/redhat-actions/push-to-registry/workflows/Multiple%20container%20CLI%20build%20tests/badge.svg)](https://github.com/redhat-actions/push-to-registry/actions?query=workflow%3A%22Multiple+container+CLI+build+tests%22)
[![Link checker](https://github.com/redhat-actions/push-to-registry/workflows/Link%20checker/badge.svg)](https://github.com/redhat-actions/push-to-registry/actions?query=workflow%3A%22Link+checker%22)
<br><br>
@ -13,6 +14,8 @@ Push-to-registry is a GitHub Action for pushing a container image to an image re
This action only runs on Linux, as it uses [podman](https://github.com/containers/Podman) to perform the push. [GitHub's Ubuntu action runners](https://github.com/actions/virtual-environments#available-environments) come with Podman preinstalled. If you are not using those runners, you must first [install Podman](https://podman.io/getting-started/installation).
To log in against a container image registry, [**podman-login**](https://github.com/redhat-actions/podman-login) can be used.
## Action Inputs
Refer to the [`podman push`](http://docs.podman.io/en/latest/markdown/podman-manifest-push.1.html) documentation for more information.
@ -22,8 +25,8 @@ Refer to the [`podman push`](http://docs.podman.io/en/latest/markdown/podman-man
| image | Name of the image you want to push. | **Required**
| tags | The tag or tags of the image to push. For multiple tags, seperate by a space. For example, `latest ${{ github.sha }}` | `latest`
| registry | URL of the registry to push the image to. Eg. `quay.io/<username>` | **Required**
| username | Username with which to authenticate to the registry. | None
| password | Password, encrypted password, or access token with which to authenticate to the registry. | None
| username | Username with which to authenticate to the registry. Required unless already logged in to the registry | None
| password | Password, encrypted password, or access token with which to authenticate to the registry. Required unless already logged in to the registry | None
| tls-verify | Verify TLS certificates when contacting the registry. Set to `false` to skip certificate verification. | `true`
| digestfile | After copying the image, write the digest of the resulting image to the file. The contents of this file are the digest output. | Auto determined from image and tag
| extra-args | Extra args to be passed to podman push. Separate arguments by newline. Do not use quotes. | None
@ -41,7 +44,7 @@ For example, `[ quay.io/username/spring-image:v1, quay.io/username/spring-image:
## Examples
The example below shows how the `push-to-registry` action can be used to push an image created by the **[buildah-build](https://github.com/redhat-actions/buildah-build)** action. **[podman-login](https://github.com/redhat-actions/podman-login)** action is used here to authenticate to quay.io to push the built image.
The example below shows how the `push-to-registry` action can be used to push an image created by the [**buildah-build**](https://github.com/redhat-actions/buildah-build) action.
```yaml
name: Build and Push Image
@ -70,13 +73,9 @@ jobs:
dockerfiles: |
./Dockerfile
- name: Log in to quay.io
uses: redhat-actions/podman-login@v1
with:
username: ${{ env.REGISTRY_USER }}
password: ${{ env.REGISTRY_PASSWORD }}
registry: quay.io
# Podman Login action (https://github.com/redhat-actions/podman-login)ccan be used
# in the previous step to log into a container registry. In that case input "username"
# "password" can be omitted in this push action.
- name: Push To quay.io
id: push-to-quay
uses: redhat-actions/push-to-registry@v2
@ -84,6 +83,8 @@ jobs:
image: ${{ steps.build-image.outputs.image }}
tags: ${{ steps.build-image.outputs.tags }}
registry: ${{ secrets.QUAY_REPO }}
username: ${{ env.REGISTRY_USER }}
password: ${{ env.REGISTRY_PASSWORD }}
- name: Use the image
run: echo "New image has been pushed to ${{ steps.push-to-quay.outputs.registry-paths }}"

2
dist/index.js vendored

File diff suppressed because one or more lines are too long

2
dist/index.js.map vendored

File diff suppressed because one or more lines are too long

View file

@ -159,7 +159,13 @@ async function run(): Promise<void> {
const registryWithoutTrailingSlash = registry.replace(/\/$/, "");
let creds = "";
if (username && password) {
if (username && !password) {
core.warning("Username is provided, but password is missing!");
}
else if (!username && password) {
core.warning("Password is provided, but username is missing!");
}
else if (username && password) {
creds = `${username}:${password}`;
}