-
Notifications
You must be signed in to change notification settings - Fork 176
Expand file tree
/
Copy pathaction.yml
More file actions
44 lines (44 loc) · 1.69 KB
/
action.yml
File metadata and controls
44 lines (44 loc) · 1.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
name: "Container Registry Login"
description: "Reusable action for logging in to container registries using workflow inputs"
inputs:
registry_provider:
required: false
gcp_service_account_key:
required: false
registry_name:
required: false
registry_url:
required: false
registry_username:
required: false
registry_password:
required: false
github_token:
required: false
runs:
using: "composite"
steps:
- run: |
case "${{ inputs.registry_provider }}" in
"gcp")
echo "Using Google Container Registry"
echo "${{ inputs.gcp_service_account_key }}" | base64 --decode > $HOME/gcloud-key.json
gcloud auth activate-service-account --key-file=$HOME/gcloud-key.json
gcloud auth configure-docker ${{ inputs.registry_name }}
REGISTRY_URL=$(echo "${{ inputs.registry_url }}" | tr '[:upper:]' '[:lower:]')
;;
"azure" | "dockerhub")
echo "Logging in to Container Registry"
echo "${{ inputs.registry_password }}" | docker login ${{ inputs.registry_name }} \
--username ${{ inputs.registry_username }} --password-stdin
REGISTRY_URL=$(echo "${{ inputs.registry_url }}" | tr '[:upper:]' '[:lower:]')
;;
*)
echo "Using GitHub Container Registry (GHCR)"
REPO_NAME_LOWERCASE=$(echo "${GITHUB_REPOSITORY}" | tr '[:upper:]' '[:lower:]')
echo "${{ inputs.github_token }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
REGISTRY_URL="ghcr.io/$REPO_NAME_LOWERCASE"
;;
esac
echo "REGISTRY_URL=${REGISTRY_URL}" >> $GITHUB_ENV
shell: bash