Skip to content

Commit b413c5e

Browse files
committed
Updated composite to take as inputs.
1 parent ee14e74 commit b413c5e

File tree

5 files changed

+68
-32
lines changed

5 files changed

+68
-32
lines changed

.github/actions/registry-login/action.yaml

Lines changed: 0 additions & 29 deletions
This file was deleted.
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: "Container Registry Login"
2+
description: "Reusable action for logging in to container registries using workflow inputs"
3+
inputs:
4+
registry_provider:
5+
required: false
6+
gcp_service_account_key:
7+
required: false
8+
registry_name:
9+
required: false
10+
registry_url:
11+
required: false
12+
registry_username:
13+
required: false
14+
registry_password:
15+
required: false
16+
github_token:
17+
required: false
18+
runs:
19+
using: "composite"
20+
steps:
21+
- run: |
22+
case "${{ inputs.registry_provider }}" in
23+
"gcp")
24+
echo "Using Google Container Registry"
25+
echo "${{ inputs.gcp_service_account_key }}" | base64 --decode > $HOME/gcloud-key.json
26+
gcloud auth activate-service-account --key-file=$HOME/gcloud-key.json
27+
gcloud auth configure-docker ${{ inputs.registry_name }}
28+
REGISTRY_URL=$(echo "${{ inputs.registry_url }}" | tr '[:upper:]' '[:lower:]')
29+
;;
30+
"azure" | "dockerhub")
31+
echo "Logging in to Container Registry"
32+
echo "${{ inputs.registry_password }}" | docker login ${{ inputs.registry_name }} \
33+
--username ${{ inputs.registry_username }} --password-stdin
34+
REGISTRY_URL=$(echo "${{ inputs.registry_url }}" | tr '[:upper:]' '[:lower:]')
35+
;;
36+
*)
37+
echo "Using GitHub Container Registry (GHCR)"
38+
REPO_NAME_LOWERCASE=$(echo "${GITHUB_REPOSITORY}" | tr '[:upper:]' '[:lower:]')
39+
echo "${{ inputs.github_token }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
40+
REGISTRY_URL="ghcr.io/$REPO_NAME_LOWERCASE"
41+
;;
42+
esac
43+
echo "REGISTRY_URL=${REGISTRY_URL}" >> $GITHUB_ENV
44+
shell: bash

.github/workflows/content-service.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,15 @@ jobs:
4040
-DCLOUD_STORE_VERSION=${{ vars.CLOUD_STORE_VERSION }}
4141
4242
# Step 5: Set up Login to Docker registry
43-
- name: Container Registry Login
43+
- name: Registry Login
4444
uses: ./.github/actions/registry-login
45+
with:
46+
registry_provider: ${{ vars.REGISTRY_PROVIDER }}
47+
gcp_service_account_key: ${{ secrets.GCP_SERVICE_ACCOUNT_KEY }}
48+
registry_name: ${{ secrets.REGISTRY_NAME }}
49+
registry_url: ${{ secrets.REGISTRY_URL }}
50+
registry_username: ${{ secrets.REGISTRY_USERNAME }}
51+
registry_password: ${{ secrets.REGISTRY_PASSWORD }}
4552

4653
# Step 6: Build Docker image
4754
- name: Build Docker Image

.github/workflows/search-service.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,15 @@ jobs:
4040
-DCLOUD_STORE_VERSION=${{ vars.CLOUD_STORE_VERSION }}
4141
4242
# Step 5: Set up Login to Docker registry
43-
- name: Container Registry Login
43+
- name: Registry Login
4444
uses: ./.github/actions/registry-login
45+
with:
46+
registry_provider: ${{ vars.REGISTRY_PROVIDER }}
47+
gcp_service_account_key: ${{ secrets.GCP_SERVICE_ACCOUNT_KEY }}
48+
registry_name: ${{ secrets.REGISTRY_NAME }}
49+
registry_url: ${{ secrets.REGISTRY_URL }}
50+
registry_username: ${{ secrets.REGISTRY_USERNAME }}
51+
registry_password: ${{ secrets.REGISTRY_PASSWORD }}
4552

4653
# Step 6: Build Docker image
4754
- name: Build Docker Image

.github/workflows/taxonomy-service.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,15 @@ jobs:
4040
-DCLOUD_STORE_VERSION=${{ vars.CLOUD_STORE_VERSION }}
4141
4242
# Step 5: Set up Login to Docker registry
43-
- name: Container Registry Login
43+
- name: Registry Login
4444
uses: ./.github/actions/registry-login
45+
with:
46+
registry_provider: ${{ vars.REGISTRY_PROVIDER }}
47+
gcp_service_account_key: ${{ secrets.GCP_SERVICE_ACCOUNT_KEY }}
48+
registry_name: ${{ secrets.REGISTRY_NAME }}
49+
registry_url: ${{ secrets.REGISTRY_URL }}
50+
registry_username: ${{ secrets.REGISTRY_USERNAME }}
51+
registry_password: ${{ secrets.REGISTRY_PASSWORD }}
4552

4653
# Step 6: Build Docker image
4754
- name: Build Docker Image

0 commit comments

Comments
 (0)