Skip to content

Commit 8d93dcb

Browse files
authored
fix: export HTTP_AUTH to github env (#17)
it's useful for some situations where we need auth for packages or whatnot --------- Signed-off-by: Luca Di Maio <luca.dimaio1@gmail.com>
1 parent a2e4820 commit 8d93dcb

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

action.yaml

+15
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,13 @@ inputs:
1414
required: true
1515
default: enforce.dev
1616

17+
env-auth:
18+
description: |
19+
Determines if we export HTTP_AUTH env variable with chainctl auth
20+
token.
21+
required: false
22+
default: false
23+
1724
identity:
1825
description: |
1926
The id of the identity that this workflow should assume for
@@ -94,6 +101,7 @@ runs:
94101
VERBOSITY: ${{ inputs.verbosity }}
95102
IDENTITY: ${{ inputs.identity }}
96103
CHAINCTL_CONFIG: ${{ inputs.config-path }}
104+
EXPORT_AUTH: ${{ inputs.env-auth }}
97105
run: |
98106
if chainctl auth login --identity "${{ env.IDENTITY }}" -v=${{ env.VERBOSITY }}; then
99107
echo Logged in as ${{ env.IDENTITY }}!
@@ -105,6 +113,9 @@ runs:
105113
echo Unable to register credential helper as ${{ env.IDENTITY }}.
106114
exit 1
107115
fi
116+
if [ "${{ env.EXPORT_AUTH }}" == "true" ]; then
117+
echo HTTP_AUTH="basic:apk.cgr.dev:user:$(shell chainctl auth token --audience apk.cgr.dev)" >> $GITHUB_ENV
118+
fi
108119
109120
- name: Authenticate with Chainguard (DEPRECATED invite-code)
110121
shell: bash
@@ -115,6 +126,7 @@ runs:
115126
VERBOSITY: ${{ inputs.verbosity }}
116127
ENVIRONMENT: ${{ inputs.environment }}
117128
AUDIENCE: ${{ inputs.audience }}
129+
EXPORT_AUTH: ${{ inputs.env-auth }}
118130
run: |
119131
echo "::warning::The use of invite codes with Github actions is deprecated, use assumed identities instead."
120132
@@ -131,3 +143,6 @@ runs:
131143
echo Failed to log in with invite code
132144
exit 1
133145
fi
146+
if [ "${{ env.EXPORT_AUTH }}" == "true" ]; then
147+
echo HTTP_AUTH="basic:apk.cgr.dev:user:$(shell chainctl auth token --audience apk.cgr.dev)" >> $GITHUB_ENV
148+
fi

0 commit comments

Comments
 (0)