-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaction.yml
115 lines (112 loc) · 3.92 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
name: 'Unleash Checker AI'
description: 'Checks and updates stale Unleash flags'
author: 'Hiroyuki Kuromiya'
inputs:
unleash_api_endpoint:
description: 'Unleash API endpoint'
required: true
unleash_api_token:
description: 'Unleash API token'
required: true
unleash_project_id:
description: 'Unleash project ID'
required: true
openai_api_key:
description: 'OpenAI API key'
required: true
target_path:
description: 'Path to the directory you want to run unleash-checker-ai in'
required: false
default: '.'
github_token:
description: 'GitHub token for creating pull requests'
required: true
github_base_url:
description: 'GitHub base URL'
required: false
default: 'https://github.com'
release_flag_lifetime:
description: 'Flag lifetime for release flags (days)'
required: false
default: '40'
experiment_flag_lifetime:
description: 'Flag lifetime for experimental flags (days)'
required: false
default: '40'
operational_flag_lifetime:
description: 'Flag lifetime for operational flags (days)'
required: false
default: '7'
permission_flag_lifetime:
description: 'Flag lifetime for permission flags (days)'
required: false
default: 'permanent'
outputs:
checker_output:
description: 'Output from unleash-checker-ai'
value: ${{ steps.unleash-checker.outputs.checker_output }}
runs:
using: 'composite'
steps:
- name: Get latest release
id: get_release
shell: bash
run: |
OS=$(echo $RUNNER_OS | tr '[:upper:]' '[:lower:]')
ARCH=$(echo $RUNNER_ARCH | tr '[:upper:]' '[:lower:]')
if [ "$ARCH" == "x64" ]; then
ARCH="amd64"
fi
RELEASE_INFO=$(curl -s https://api.github.com/repos/kromiii/unleash-checker-ai/releases/latest)
ASSET_URL=$(echo "$RELEASE_INFO" | jq -r ".assets[] | select(.name | contains(\"$OS\") and contains(\"$ARCH\")) | .browser_download_url")
if [ -z "$ASSET_URL" ]; then
echo "Error: No matching asset found for $OS-$ARCH"
exit 1
fi
echo "asset_url=$ASSET_URL" >> $GITHUB_OUTPUT
echo "version=$(echo "$RELEASE_INFO" | jq -r .tag_name)" >> $GITHUB_OUTPUT
- name: Download unleash-checker-ai
shell: bash
run: |
cd $GITHUB_WORKSPACE
mkdir -p unleash-checker-ai-tmp
cd unleash-checker-ai-tmp
wget ${{ steps.get_release.outputs.asset_url }} -O unleash-checker-ai.tar.gz
tar -xzf unleash-checker-ai.tar.gz
chmod +x unleash-checker-ai
mv unleash-checker-ai ..
cd ..
rm -rf unleash-checker-ai-tmp
- name: Run unleash-checker-ai
id: unleash-checker
shell: bash
env:
UNLEASH_API_ENDPOINT: ${{ inputs.unleash_api_endpoint }}
UNLEASH_API_TOKEN: ${{ inputs.unleash_api_token }}
UNLEASH_PROJECT_ID: ${{ inputs.unleash_project_id }}
OPENAI_API_KEY: ${{ inputs.openai_api_key }}
GITHUB_BASE_URL: ${{ inputs.github_base_url }}
GITHUB_TOKEN: ${{ inputs.github_token }}
GITHUB_OWNER: ${{ github.repository_owner }}
GITHUB_REPO: ${{ github.event.repository.name }}
RELEASE_FLAG_LIFETIME: ${{ inputs.release_flag_lifetime }}
EXPERIMENT_FLAG_LIFETIME: ${{ inputs.experiment_flag_lifetime }}
OPERATIONAL_FLAG_LIFETIME: ${{ inputs.operational_flag_lifetime }}
PERMISSION_FLAG_LIFETIME: ${{ inputs.permission_flag_lifetime }}
run: |
set +e
output=$(./unleash-checker-ai ${{ inputs.target_path }} 2>&1)
exit_code=$?
set -e
echo "checker_output<<EOF" >> $GITHUB_OUTPUT
echo "$output" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
rm unleash-checker-ai
echo "$output"
if [ $exit_code -ne 0 ]; then
echo "Error: unleash-checker-ai exited with code $exit_code"
exit $exit_code
fi
branding:
icon: 'check-circle'
color: 'green'