Skip to content

Commit

Permalink
🐛 Fix correct value fail
Browse files Browse the repository at this point in the history
  • Loading branch information
yi-Xu-0100 committed Oct 23, 2020
1 parent b87b68f commit 08f7946
Show file tree
Hide file tree
Showing 6 changed files with 71 additions and 55 deletions.
47 changes: 26 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,39 +30,48 @@ The GitHub action that using repositories `Insights/traffic` data to generate ba
```yaml
inputs:
my_token:
description: 'Set up a personal access token to obtain the secret repository traffic data.'
description: >
Set up a personal access token to obtain the secret repository traffic data.
required: true
static_list:
description: 'Set up a list of repositories to get.'
required: true
description: >
Set up a list of repositories to get.
Only when github.repository with setting into first item,
it can be correct to be current repository name.
required: false
default: ${{ github.repository }}
traffic_branch:
description: 'If empty traffic data will be backed up to the branch named traffic.'
description: >
If empty traffic data will be backed up to the branch named traffic.
required: false
default: 'traffic'
default: traffic
views_color:
description: 'Set a hex or named color value for the views badge background.'
description: >
Set a hex or named color value for the views badge background.
required: false
default: 'brightgreen'
default: brightgreen
clones_color:
description: 'Set a hex or named color value for the clones badge background.'
description: >
Set a hex or named color value for the clones badge background.
required: false
default: 'brightgreen'
default: brightgreen
logo:
description: 'Insert a named logo or simple-icon to the left of the label.'
description: >
Insert a named logo or simple-icon to the left of the label.
required: false
default: 'github'
default: github

outputs:
traffic_branch:
description: 'Origin traffic data branch name'
description: >
Origin traffic data branch name
traffic_path:
description: 'Path to generate traffic data'
description: >
Path to generate traffic data
```
## 📝 Example usage
**[`repo-list-generator`](https://github.com/marketplace/actions/repo-list-generator): The output `repo` only include current repository name.**

```yaml
name: traffic2badge
on:
Expand All @@ -80,16 +89,12 @@ jobs:
- name: Checkout Code
uses: actions/[email protected]

- name: Get Repo List
id: repo
uses: yi-Xu-0100/[email protected]
- name: Get Traffic
id: traffic
uses: yi-Xu-0100/[email protected]
with:
my_token: ${{ secrets.TRAFFIC_TOKEN }}
static_list: ${{ steps.repo.outputs.repo }}
#(default) static_list: ${{ github.repository }}
#(default) traffic_branch: traffic
#(default) views_color: brightgreen
#(default) clones_color: brightgreen
Expand All @@ -105,7 +110,7 @@ jobs:
**More usage example:**
- [yi-Xu-0100/traffic2badge](https://github.com/yi-Xu-0100/traffic2badge) - Template repository for usage.
- [`yi-Xu-0100/traffic2badge`](https://github.com/yi-Xu-0100/traffic2badge) - Template repository for usage with [`yi-Xu-0100/repo-list-generator`] which generate `repoList` for `static_list`.

## 📝 Use dependabot to keep action up-to-date

Expand Down
40 changes: 22 additions & 18 deletions README_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,39 +30,47 @@
```yaml
input:
my_token:
description: '设置用以获取私密存储库流量数据的个人访问令牌。'
description: >
'设置用以获取私密存储库流量数据的个人访问令牌。'
required: true
static_list:
description: '设置一个想要获取的存储库列表。'
required: true
description: >
'设置一个想要获取的存储库列表。
只有 github.repository 设置为第一个值时才可以被修正为当前仓库名。'
required: false
default: ${{ github.repository }}
traffic_branch:
description: '如果为空,则流量数据将备份到名为 traffic 的分支中。'
description: >
'如果为空,则流量数据将备份到名为 traffic 的分支中。'
required: false
default: 'traffic'
views_color:
description: '为 views 徽章背景设置一个十六进制或命名的颜色值。'
description: >
'为 views 徽章背景设置一个十六进制或命名的颜色值。'
required: false
default: 'brightgreen'
clones_color:
description: '为 clones 徽章背景设置一个十六进制或命名的颜色值。'
description: >
'为 clones 徽章背景设置一个十六进制或命名的颜色值。'
required: false
default: 'brightgreen'
logo:
description: '在标签左侧插入命名的徽标或简单图标。'
description: >
'在标签左侧插入命名的徽标或简单图标。'
required: false
default: 'github'

outputs:
traffic_branch:
description: '原 traffic 分支名'
description: >
'原 traffic 分支名'
traffic_path:
description: '生成 traffic 数据的路径'
description: >
'生成 traffic 数据的路径'
```
## 📝 示例
**[`repo-list-generator`](https://github.com/marketplace/actions/repo-list-generator) :输出值 `repo` 仅包含当前仓库名称。**

```yaml
name: traffic2badge
on:
Expand All @@ -80,16 +88,12 @@ jobs:
- name: Checkout Code
uses: actions/[email protected]

- name: Get Repo List
id: repo
uses: yi-Xu-0100/[email protected]
- name: Get Traffic
id: traffic
uses: yi-Xu-0100/[email protected]
with:
my_token: ${{ secrets.TRAFFIC_TOKEN }}
static_list: ${{ steps.repo.outputs.repo }}
#(default) static_list: ${{ github.repository }}
#(default) traffic_branch: traffic
#(default) views_color: brightgreen
#(default) clones_color: brightgreen
Expand All @@ -105,7 +109,7 @@ jobs:
**更多使用示例:**
- [yi-Xu-0100/traffic2badge](https://github.com/yi-Xu-0100/traffic2badge) - 模板仓库.
- [`yi-Xu-0100/traffic2badge`](https://github.com/yi-Xu-0100/traffic2badge) - 使用 [`yi-Xu-0100/repo-list-generator`] 的模板仓库,其中 `repo-list-generator` 产生 `repoList` 用于 `static_list`.

## 📝 使用 `dependabot` 使 `action` 保持更新

Expand All @@ -123,7 +127,7 @@ updates:

## 🙈 生成 `my_token`

> 这部分是从 [sangonzal/repository-traffic-action](https://github.com/sangonzal/repository-traffic-action) 获得的。
> 这部分是从 [`sangonzal/repository-traffic-action`](https://github.com/sangonzal/repository-traffic-action) 获得的。

首先,您需要创建一个个人访问令牌(`PAT`),使该操作可以访问 `GitHub API`。

Expand Down
27 changes: 18 additions & 9 deletions action.yml
Original file line number Diff line number Diff line change
@@ -1,43 +1,52 @@
name: Traffic to Badge
author: yi_Xu
description: Use repository traffic data to generate badges that include views and clones.
description: >
Use repository traffic data to generate badges that include views and clones.
branding:
icon: award
color: green

inputs:
my_token:
description: Set up a personal access token to obtain the secret repository traffic data.
description: >
Set up a personal access token to obtain the secret repository traffic data.
required: true
static_list:
description: >
Set up a list of repositories to get.
Only default value can be calculate to be current repository name.
Only when github.repository with setting into first item,
it can be correct to be current repository name.
required: false
default: ${{ github.repository }}
traffic_branch:
description: If empty traffic data will be backed up to the branch named traffic.
description: >
If empty traffic data will be backed up to the branch named traffic.
required: false
default: traffic
views_color:
description: Set a hex or named color value for the views badge background.
description: >
Set a hex or named color value for the views badge background.
required: false
default: brightgreen
clones_color:
description: Set a hex or named color value for the clones badge background.
description: >
Set a hex or named color value for the clones badge background.
required: false
default: brightgreen
logo:
description: Insert a named logo or simple-icon to the left of the label.
description: >
Insert a named logo or simple-icon to the left of the label.
required: false
default: github

outputs:
traffic_branch:
description: Origin traffic data branch name
description: >
Origin traffic data branch name
traffic_path:
description: Path to generate traffic data
description: >
Path to generate traffic data
runs:
using: node12
Expand Down
5 changes: 2 additions & 3 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

5 changes: 2 additions & 3 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,8 @@ async function run() {
try {
info('[INFO]: Usage https://github.com/yi-Xu-0100/traffic-to-badge#readme');
startGroup('Get input value');
var static_list = getInput('static_list', { require: false });
if (static_list === process.env.GITHUB_REPOSITORY) static_list.split(`/`).shift();
else static_list = static_list.split(`,`);
var static_list = getInput('static_list', { require: false }).split(`,`);
static_list[0] = static_list[0].split(`/`).pop();
info(`[INFO]: static_list: ${static_list}`);
const traffic_branch = getInput('traffic_branch', { require: false });
info(`[INFO]: traffic_branch: ${traffic_branch}`);
Expand Down

0 comments on commit 08f7946

Please sign in to comment.