Skip to content

Instantly share code, notes, and snippets.

@nickboldt
Last active December 2, 2020 21:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nickboldt/a884449ada7a6cdcda85e58c984b5eea to your computer and use it in GitHub Desktop.
Save nickboldt/a884449ada7a6cdcda85e58c984b5eea to your computer and use it in GitHub Desktop.
2 ways to do github action to authenticate against registry.redhat.io
name: Test crw-build token for authenticated connection to RHEC (option 1)
# note, this only works against pull requests from the origin fork (redhat-developer, eclipse), not from personal forks,
# as secrets cannot be copied to user forks and end up being blank
on: [pull_request]
jobs:
job1:
runs-on: ubuntu-18.04
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Login to RHEC
uses: docker/login-action@v1
with:
username: ${{ secrets.CRW_BUILD_USER }}
password: ${{ secrets.CRW_BUILD_TOKEN }}
registry: registry.redhat.io
- name: Test authenticated connection
run: |
set -x
set +e
docker pull registry.redhat.io/codeready-workspaces/imagepuller-rhel8:2.5
name: Test crw-build token for authenticated connection to RHEC (option 2)
# note, this only works against pull requests from the origin fork (redhat-developer, eclipse), not from personal forks,
# as secrets cannot be copied to user forks and end up being blank
on: [pull_request]
jobs:
job1:
runs-on: ubuntu-18.04
env:
CRW_BUILD_USER: ${{ secrets.CRW_BUILD_USER }}
CRW_BUILD_TOKEN: ${{ secrets.CRW_BUILD_TOKEN }}
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Login to RHEC + test authenticated connection
run: |
set -x
set +e
echo "[INFO]: Log into registry.redhat.io as ${CRW_BUILD_USER} ..."
echo "${CRW_BUILD_TOKEN}" | docker login -u="${CRW_BUILD_USER}" --password-stdin registry.redhat.io
docker pull registry.redhat.io/codeready-workspaces/imagepuller-rhel8:2.5
@nickboldt
Copy link
Author

nickboldt commented Dec 2, 2020

Output from v1:

Run docker/login-action@v1
🔑 Logging into registry.redhat.io...
🎉 Login Succeeded!

then

+ docker login '-u=***' --password-stdin registry.redhat.io
+ echo ***
WARNING! Your password will be stored unencrypted in /home/runner/.docker/config.json.
Configure a credential helper to remove this warning. See
https://docs.docker.com/engine/reference/commandline/login/#credentials-store
Login Succeeded

+ docker pull registry.redhat.io/codeready-workspaces/imagepuller-rhel8:2.5
2.5: Pulling from codeready-workspaces/imagepuller-rhel8
...
Digest: sha256:b2900088e0046b5cac8e3409b83ec5d6b823cac7aff5a35412ae56ec4402f0bc
Status: Downloaded newer image for registry.redhat.io/codeready-workspaces/imagepuller-rhel8:2.5
registry.redhat.io/codeready-workspaces/imagepuller-rhel8:2.5

Output from v2:

Run set -x
+ set +e
+ echo '[INFO]: Log into registry.redhat.io as *** ...'
+ echo ***
+ docker login '-u=***' --password-stdin registry.redhat.io
[INFO]: Log into registry.redhat.io as *** ...
WARNING! Your password will be stored unencrypted in /home/runner/.docker/config.json.
Configure a credential helper to remove this warning. See
Login Succeeded
https://docs.docker.com/engine/reference/commandline/login/#credentials-store

+ docker pull registry.redhat.io/codeready-workspaces/imagepuller-rhel8:2.5
2.5: Pulling from codeready-workspaces/imagepuller-rhel8
...
Digest: sha256:b2900088e0046b5cac8e3409b83ec5d6b823cac7aff5a35412ae56ec4402f0bc
Status: Downloaded newer image for registry.redhat.io/codeready-workspaces/imagepuller-rhel8:2.5
registry.redhat.io/codeready-workspaces/imagepuller-rhel8:2.5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment