Skip to content

Commit

Permalink
chore: update registry login to happen in the common env setup action (
Browse files Browse the repository at this point in the history
  • Loading branch information
Racer159 committed Mar 27, 2024
1 parent 9c47868 commit b7bce88
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 57 deletions.
26 changes: 17 additions & 9 deletions .github/actions/setup/action.yaml
Expand Up @@ -2,12 +2,12 @@ name: Setup Environment
description: UDS Environment Setup

inputs:
username:
description: registry1 user
required: true
password:
description: registry1 password
required: true
registry1Username:
description: Registry1 Username
registry1Password:
description: Registry1 Password
ghToken:
description: GitHub Token

runs:
using: composite
Expand All @@ -26,8 +26,16 @@ runs:
run: brew install defenseunicorns/tap/uds@0.9.4

- name: Iron Bank Login
if: ${{ inputs.registry1Username != '' }}
env:
REGISTRY_USERNAME: ${{ inputs.username }}
REGISTRY_PASSWORD: ${{ inputs.password }}
run: uds zarf tools registry login -u "${{ env.REGISTRY_USERNAME }}" -p "${{ env.REGISTRY_PASSWORD }}" registry1.dso.mil
REGISTRY_USERNAME: ${{ inputs.registry1Username }}
REGISTRY_PASSWORD: ${{ inputs.registry1Password }}
run: echo "${{ env.REGISTRY_PASSWORD }}" | uds zarf tools registry login -u "${{ env.REGISTRY_USERNAME }}" --password-stdin registry1.dso.mil
shell: bash

- name: GHCR Login
if: ${{ inputs.ghToken != '' }}
env:
GH_TOKEN: ${{ inputs.ghToken }}
run: echo "${{ env.GH_TOKEN }}" | uds zarf tools registry login -u "dummy" --password-stdin ghcr.io
shell: bash
14 changes: 3 additions & 11 deletions .github/workflows/test-deploy.yaml
Expand Up @@ -32,17 +32,9 @@ jobs:
- name: Environment setup
uses: ./.github/actions/setup
with:
username: ${{ secrets.IRON_BANK_ROBOT_USERNAME }}
password: ${{ secrets.IRON_BANK_ROBOT_PASSWORD }}

- name: Login to ghcr
env:
REGISTRY: ghcr.io
REGISTRY_USERNAME: dummy
REGISTRY_PASSWORD: ${{ secrets.GITHUB_TOKEN }}
REGISTRY_RETRY_INTERVAL: "5"
run: |
uds run registry-login
registry1Username: ${{ secrets.IRON_BANK_ROBOT_USERNAME }}
registry1Password: ${{ secrets.IRON_BANK_ROBOT_PASSWORD }}
ghToken: ${{ secrets.GITHUB_TOKEN }}

- name: Test
uses: ./.github/actions/test
Expand Down
10 changes: 0 additions & 10 deletions tasks.yaml
Expand Up @@ -6,16 +6,6 @@ includes:
- publish: ./tasks/publish.yaml

tasks:
- name: registry-login
description: Authenticate to registry (registry1 defualt)
actions:
- task: setup:registry-login
with:
registry: ${REGISTRY}
registryUsername: ${REGISTRY_USERNAME}
registryPassword: ${REGISTRY_PASSWORD}
registryRetryInterval: ${REGISTRY_RETRY_INTERVAL}

- name: create-podinfo-package
description: Create UDS Podinfo Package
actions:
Expand Down
27 changes: 0 additions & 27 deletions tasks/setup.yaml
Expand Up @@ -8,30 +8,3 @@ tasks:
- description: Create k3d cluster with UDS Core Istio
# renovate: datasource=github-tags depName=defenseunicorns/uds-core versioning=semver
cmd: uds deploy oci://defenseunicorns/uds/bundles/k3d-core-slim-dev:0.17.0 --confirm --no-progress

- name: registry-login
inputs:
registry:
description: Registry
registryUsername:
description: Registry username
registryPassword:
description: Registry password
registryRetryInterval:
default: "5"
description: Registry retry interval
actions:
- cmd: |
echo ${{ .inputs.registryPassword }} | \
uds zarf tools registry login \
--username ${{ .inputs.registryUsername }} \
--password-stdin ${{ .inputs.registry }} \
>/dev/null
description: Authenticate to the registry
- cmd: |
if [ ${{ .inputs.registry }} = "registry1.dso.mil" ]; then
uds zarf tools registry digest "${REGISTRY1_TEST_IMAGE}" >/dev/null || \
(sleep ${{ .inputs.registryRetryInterval }}; exit 1)
fi
description: Validate registry connection
maxRetries: 10

0 comments on commit b7bce88

Please sign in to comment.