Skip to content

Commit 911623d

Browse files
authored
Merge pull request #26 from kyoshidajp/add_action.yaml
Add composite GitHub Action
2 parents fa0e957 + 2db4625 commit 911623d

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

action.yml

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
inputs:
2+
version:
3+
description: "A version to install dep-doctor"
4+
default: latest
5+
required: false
6+
github-token:
7+
description: "The token used when calling GitHub API"
8+
required: false
9+
default: ${{ github.token }}
10+
runs:
11+
using: "composite"
12+
steps:
13+
- shell: bash
14+
env:
15+
github_token: ${{ inputs.github-token }}
16+
run: |
17+
set -e
18+
VERSION="${{ inputs.version }}"
19+
if [ -n "${{ inputs.version-file }}" ]; then
20+
VERSION="v$(cat ${{ inputs.version-file }})"
21+
fi
22+
api_request_args=("-sS")
23+
if [[ -n "$github_token" ]]; then
24+
api_request_args=("${api_request_args[@]}" -H "authorization: token $github_token")
25+
fi
26+
if [ "${VERSION}" = "latest" ]; then
27+
DOWNLOAD_URL=$(curl "${api_request_args[@]}" https://api.github.com/repos/kyoshidajp/dep-doctor/releases | jq -r '[.[]|select(.tag_name > "v0.2")][0].assets[].browser_download_url|select(match("Linux_arm64."))')
28+
else
29+
DOWNLOAD_URL=https://github.com/kyoshidajp/dep-doctor/releases/download/${VERSION}/dep-doctor_Linux_arm64.tar.gz
30+
fi
31+
mkdir -p ${RUNNER_TOOL_CACHE}/dep-doctor
32+
cd /tmp
33+
curl -sfLO ${DOWNLOAD_URL}
34+
if [[ "${DOWNLOAD_URL}" =~ \.tar\.gz$ ]]; then
35+
FILENAME=$(basename $DOWNLOAD_URL .tar.gz)
36+
tar xzvf ${FILENAME}.tar.gz
37+
sudo install dep-doctor ${RUNNER_TOOL_CACHE}/dep-doctor/dep-doctor
38+
elif [[ "${DOWNLOAD_URL}" =~ \.zip$ ]]; then
39+
FILENAME=$(basename $DOWNLOAD_URL .zip)
40+
unzip ${FILENAME}.zip
41+
sudo install ${FILENAME} ${RUNNER_TOOL_CACHE}/dep-doctor/dep-doctor
42+
fi
43+
44+
echo "Adding ${RUNNER_TOOL_CACHE}/dep-doctor to path..."
45+
echo "${RUNNER_TOOL_CACHE}/dep-doctor" >> $GITHUB_PATH
46+
"${RUNNER_TOOL_CACHE}/dep-doctor/depdoctor" version

0 commit comments

Comments
 (0)