Debian Codegraph @

ansible_collections/community/hashi_vault/.github/actions/collection-via-git/action.yml

raw
1 ---
2 name: Ansible Collection via GitHub
3 description: Install Ansible collections direct from GitHub repositories without using ansible-galaxy.
4 branding:
5 icon: git-branch
6 color: yellow
7 inputs:
8 collection:
9 description: The name of the collection in namespace.collection_name form.
10 required: true
11 ref:
12 description: The git ref to install. Defaults to the latest release as listed in GitHub releases. Only supports branches and tags.
13 required: false
14 path:
15 description: The path to clone it to. Defaults to ansible_collections/namespace/collection_name.
16 required: false
17 runs:
18 using: composite
19 steps:
20 - shell: bash
21 run: |
22 COLLECTION="${{ inputs.collection }}"
23 P_PATH="${{ inputs.path }}"
24 P_REF="${{ inputs.ref }}"
25
26 NS="${COLLECTION%.*}"
27 CN="${COLLECTION#*.}"
28
29 # only collections in the ansible-collections organization are supported right now
30 URLBASE="https://github.com/ansible-collections/${COLLECTION}"
31 URLCLONE="${URLBASE}.git"
32 URLLATEST="${URLBASE}/releases/latest"
33
34 if [[ -n "${P_PATH}" ]]
35 then
36 OUTPATH="${P_PATH}"
37 else
38 OUTPATH="ansible_collections/${NS}/${CN}"
39 fi
40
41 if [[ -n "${P_REF}" ]]
42 then
43 REF="${P_REF}"
44 else
45 # credit to https://gist.github.com/lukechilds/a83e1d7127b78fef38c2914c4ececc3c#gistcomment-3294173
46 latest=$(curl -fs -o/dev/null -w %{redirect_url} "${URLLATEST}")
47 REF=$(basename ${latest})
48 fi
49
50 git clone --depth=1 --branch "${REF}" "${URLCLONE}" "${OUTPATH}"