-
Notifications
You must be signed in to change notification settings - Fork 0
/
action.yml
56 lines (47 loc) · 1.89 KB
/
action.yml
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
45
46
47
48
49
50
51
52
53
54
55
56
name: 'setup-gh'
description: 'Setup Github CLI on workflows with custom linux container'
branding:
icon: 'play-circle'
color: 'blue'
inputs:
repository:
description: 'Repository setting for Github CLI'
required: false
default: ${{ github.repository }}
token:
description: 'Authentication token setting for Github CLI'
required: false
default: ${{ github.token }}
runs:
using: 'composite'
steps:
# This is only triggered on Linux os,
# as the only case for which we need to install gh is
# when we use an custom container.
# For which only Linux runner can config one.
- name: Install gh
if: runner.os == 'Linux'
shell: bash
run: |
# This script installs Github CLI according to the official guide:
# See: https://github.com/cli/cli/blob/trunk/docs/install_linux.md
if type -p gh > /dev/null
then
echo "Github Cli has already been installed"
else
echo "::group::Install Github CLI"
type -p curl >/dev/null || (apt-get update && apt-get install curl -y)
curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg &&
chmod go+r /usr/share/keyrings/githubcli-archive-keyring.gpg &&
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | tee /etc/apt/sources.list.d/github-cli.list > /dev/null &&
apt-get update && apt-get install gh -y
echo "::endgroup::"
fi
- name: Set Environment Variables
shell: bash
run: |
echo "GH_REPO=${{ inputs.repository }}" >> $GITHUB_ENV
echo "GH_TOKEN=${{ inputs.token }}" >> $GITHUB_ENV
- name: Print gh version
shell: bash
run: gh --version