Skip to content

Commit 10ecb6a

Browse files
committed
Update action.yml
1 parent 19f2154 commit 10ecb6a

File tree

1 file changed

+47
-20
lines changed

1 file changed

+47
-20
lines changed

.github/actions/docker-setup/action.yml

Lines changed: 47 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,25 @@ description: Docker Setup (install, qemu, buildx and login)
44

55
inputs:
66
git_url:
7-
description: "Git-URL from Workflow"
7+
description: "Git-URL/Registry-Domain from Workflow"
88
required: false
99
#default: 'ghcr.io'
10+
#default: ${{ github.server_url == 'https://github.com' && 'ghcr.io' || '' }}
1011
git_username:
1112
description: "Git-Username variable from Workflow"
1213
required: false
14+
default: ${{ github.repository_owner }} # ${{ github.repository_owner }} or ${{ github.actor }}
1315
git_token:
1416
description: "Git-Token secret from Workflow"
1517
required: false
18+
git_buildx_insecure_mode:
19+
description: "Mode: none|insecure|custom-ca"
20+
required: false
21+
default: 'none'
22+
git_buildx_ca_path:
23+
description: "Path to CA chain file for custom-ca"
24+
required: false
25+
default: '/etc/ssl/certs/ca-chain.crt'
1626
docker_username:
1727
description: "Docker Username variable from Workflow"
1828
required: false
@@ -46,19 +56,35 @@ runs:
4656
fi
4757
echo "GIT_URL=$GIT_URL" >> "$GITHUB_ENV"
4858
49-
GIT_USERNAME="${{ inputs.git_username }}"
50-
if [[ -z "$GIT_USERNAME" ]]; then
51-
GIT_USERNAME="${{github.repository_owner}}"
52-
#GIT_USERNAME="${{github.actor}}"
53-
fi
54-
echo "GIT_USERNAME=$GIT_USERNAME" >> "$GITHUB_ENV"
59+
- name: Create buildx config
60+
id: buildx_config
61+
shell: bash
62+
run: |
63+
MODE="${{ inputs.git_buildx_insecure_mode }}"
64+
REGISTRY="${{ env.GIT_URL }}"
65+
66+
case "$MODE" in
67+
"none") echo "config<<EOF" >> $GITHUB_OUTPUT && echo "" >> $GITHUB_OUTPUT && echo "EOF" >> $GITHUB_OUTPUT ;;
68+
"insecure")
69+
echo "config<<EOF" >> $GITHUB_OUTPUT
70+
echo "[registry.\"$REGISTRY\"]" >> $GITHUB_OUTPUT
71+
echo " insecure = true" >> $GITHUB_OUTPUT
72+
echo "EOF" >> $GITHUB_OUTPUT ;;
73+
"custom-ca")
74+
echo "config<<EOF" >> $GITHUB_OUTPUT
75+
echo "[registry.\"$REGISTRY\"]" >> $GITHUB_OUTPUT
76+
echo " ca = [\"${{ inputs.git_buildx_ca_path }}\"]" >> $GITHUB_OUTPUT
77+
echo "EOF" >> $GITHUB_OUTPUT ;;
78+
esac
79+
80+
echo "::debug::Buildx Config:\n$CONFIG"
5581
5682
- name: Debug Variables
5783
id: debug
5884
shell: bash
5985
run: |
6086
echo "GIT_URL=${{ env.GIT_URL }}"
61-
echo "GIT_USERNAME=${{ env.GIT_USERNAME }}"
87+
echo "GIT_USERNAME=${{ inputs.git_username }}"
6288
echo "DOCKER_USERNAME=${{ inputs.docker_username }}"
6389
echo "QUAY_USERNAME=${{ inputs.quay_username }}"
6490
@@ -82,19 +108,20 @@ runs:
82108
- name: Set up Docker Buildx
83109
id: buildx
84110
uses: docker/setup-buildx-action@v3
111+
with:
112+
buildkitd-config-inline: ${{ steps.buildx_config.outputs.config }}
85113
#with:
86-
# config-inline: |
114+
# buildkitd-config-inline: |
87115
# [registry."${{ env.GIT_URL }}"]
88116
# #insecure = true
89-
# #ca=["/etc/ssl/certs/ca-certificates.crt"]
90-
# ca=["/etc/ssl/certs/fullca.crt"]
117+
# ca=["/etc/ssl/certs/ca-chain.crt"]
91118

92119
- name: Login to GIT Container Registry
93-
if: env.GIT_URL != '' && env.GIT_USERNAME != '' && inputs.git_token != ''
120+
if: env.GIT_URL != '' && inputs.git_username != '' && inputs.git_token != ''
94121
uses: docker/login-action@v3
95122
with:
96123
registry: ${{ env.GIT_URL }}
97-
username: ${{ env.GIT_USERNAME }}
124+
username: ${{ inputs.git_username }}
98125
password: ${{ inputs.git_token }}
99126

100127
- name: Login to Docker Hub Container Registry
@@ -105,13 +132,13 @@ runs:
105132
username: ${{ inputs.docker_username }}
106133
password: ${{ inputs.docker_password }}
107134

108-
#- name: Login to Docker Hardened Images Container Registry
109-
# if: inputs.docker_username != '' && inputs.docker_password != ''
110-
# uses: docker/login-action@v3
111-
# with:
112-
# registry: dhi.io
113-
# username: ${{ inputs.docker_username }}
114-
# password: ${{ inputs.docker_password }}
135+
- name: Login to Docker Hardened Images Container Registry
136+
if: inputs.docker_username != '' && inputs.docker_password != ''
137+
uses: docker/login-action@v3
138+
with:
139+
registry: dhi.io
140+
username: ${{ inputs.docker_username }}
141+
password: ${{ inputs.docker_password }}
115142

116143
- name: Login to RED HAT Quay.io Container Registry
117144
if: inputs.quay_username != '' && inputs.quay_password != ''

0 commit comments

Comments
 (0)