# traffic2badge **Repository Path**: yiXu0100/traffic2badge ## Basic Information - **Project Name**: traffic2badge - **Description**: 使用 traffic-to-badge GitHub action 的模板仓库 - **Primary Language**: Unknown - **License**: MIT - **Default Branch**: main - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2020-10-22 - **Last Updated**: 2022-10-29 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # ⚡️ traffic2badge [![sync2gitee(list)]()](https://github.com/yi-Xu-0100/hub-mirror) [![traffic2badge](https://github.com/yi-Xu-0100/traffic2badge/workflows/traffic2badge/badge.svg)](https://github.com/yi-Xu-0100/traffic2badge/actions?query=workflow%3Atraffic2badge) [![GitHub last commit](https://img.shields.io/github/last-commit/yi-Xu-0100/traffic2badge)](./) [![LICENSE](https://img.shields.io/github/license/yi-Xu-0100/traffic2badge)](./LICENSE) [![GitHub views](https://raw.githubusercontent.com/yi-Xu-0100/traffic2badge/traffic/traffic-traffic2badge/views.svg)](https://github.com/yi-Xu-0100/traffic2badge/tree/traffic) [![GitHub views per week](https://raw.githubusercontent.com/yi-Xu-0100/traffic2badge/traffic/traffic-traffic2badge/views_per_week.svg)](https://github.com/yi-Xu-0100/traffic2badge/tree/traffic) [![GitHub clones](https://raw.githubusercontent.com/yi-Xu-0100/traffic2badge/traffic/traffic-traffic2badge/clones.svg)](https://github.com/yi-Xu-0100/traffic2badge/tree/traffic) [![GitHub clones per week](https://raw.githubusercontent.com/yi-Xu-0100/traffic2badge/traffic/traffic-traffic2badge/clones_per_week.svg)](https://github.com/yi-Xu-0100/traffic2badge/tree/traffic) [![total views](https://raw.githubusercontent.com/yi-Xu-0100/traffic2badge/traffic/total_views.svg)](https://github.com/yi-Xu-0100/traffic2badge/tree/traffic#-total-traffic-data-badge) [![total views per week](https://raw.githubusercontent.com/yi-Xu-0100/traffic2badge/traffic/total_views_per_week.svg)](https://github.com/yi-Xu-0100/traffic2badge/tree/traffic#-total-traffic-data-badge) [![total clones](https://raw.githubusercontent.com/yi-Xu-0100/traffic2badge/traffic/total_clones.svg)](https://github.com/yi-Xu-0100/traffic2badge/tree/traffic#-total-traffic-data-badge) [![total clones per week](https://raw.githubusercontent.com/yi-Xu-0100/traffic2badge/traffic/total_clones_per_week.svg)](https://github.com/yi-Xu-0100/traffic2badge/tree/traffic#-total-traffic-data-badge) 本模板仓库使用 [traffic-to-badge GitHub Action](https://github.com/marketplace/actions/traffic-to-badge),您可以使用存储库 `Insights/traffic` 数据来生成包含浏览数和克隆数的徽章。 [**简体中文**](./README_CN.md) | [English](./README.md) ## 🎨 目录 - [🎨 目录](#-目录) - [🚀 配置说明](#-配置说明) - [📝 使用 `static_list` 的示例](#-使用-static_list-的示例) - [🎉 鸣谢](#-鸣谢) - [📄 协议](#-协议) ## 🚀 配置说明 **仅仅必须设置一个输入参数**,并且有四个输入参数会使用默认值而无需设置,默认设置只支持运行仓库,需要多仓库支持,请参考[使用 `static_list` 的示例](#-使用-static_list-的示例)。 | 输入参数 | 描述 | required | default | | :---------------------: | :--------------------------------------: | :------: | :---------------: | | my_token | 用以获取私密存储库流量数据的个人访问令牌 | ✔ | | | static_list | 想要获取的存储库列表 | ✖ | github.repository | | traffic_branch | 用于备份流量数据的分支 | ✖ | traffic | | views_color | 浏览数徽章背景的颜色值 | ✖ | brightgreen | | clones_color | 克隆数徽章背景的颜色值 | ✖ | brightgreen | | views_week_color | 过去一周浏览数徽章背景的颜色值 | ✖ | brightgreen | | clones_week_color | 过去一周克隆数徽章背景的颜色值 | ✖ | brightgreen | | total_views_color | 所有仓库浏览数徽章背景的颜色值 | ✖ | brightgreen | | total_clones_color | 所有仓库克隆数徽章背景的颜色值 | ✖ | brightgreen | | total_views_week_color | 所有仓库过去一周浏览数徽章背景的颜色值 | ✖ | brightgreen | | total_clones_week_color | 所有仓库过去一周克隆数徽章背景的颜色值 | ✖ | brightgreen | | logo | 标签左侧的徽标或者简单图标 | ✖ | github | | year | 许可证起始年份 | ✖ | | ### 📝 使用 `static_list` 的示例 **[`repo-list-generator`](https://github.com/marketplace/actions/repo-list-generator) :默认存储库列表不包括 `private` 存储库和 `fork` 存储库。** ```yaml name: traffic2badge on: push: schedule: - cron: '1 0 * * *' jobs: run: name: Make GitHub Traffic to Badge runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/checkout@v2.3.4 - name: Get Repo List id: repo uses: yi-Xu-0100/repo-list-generator@v0.4.1 - name: Get Commit Message id: message uses: actions/github-script@v3.1.0 env: FULL_COMMIT_MESSAGE: '${{ github.event.head_commit.message }}' with: result-encoding: string script: | var message = `${process.env.FULL_COMMIT_MESSAGE}`; core.info(message); if (message != '') return message; var time = new Date(Date.now()).toISOString(); core.info(time); return `Get traffic data at ${time}`; - name: Set traffic id: traffic uses: yi-Xu-0100/traffic-to-badge@v1.4.0 with: my_token: ${{ secrets.TRAFFIC_TOKEN }} static_list: '${{ steps.repo.outputs.repoList }}' #(default) traffic_branch: traffic #(default) views_color: brightgreen #(default) clones_color: brightgreen #(default) views_week_color: brightgreen #(default) clones_week_color: brightgreen #(default) total_views_color: brightgreen #(default) total_clones_color: brightgreen #(default) total_views_week_color: brightgreen #(default) total_clones_week_color: brightgreen #(default) logo: github year: 2021 - name: Deploy uses: peaceiris/actions-gh-pages@v3.7.3 with: github_token: ${{ secrets.GITHUB_TOKEN }} publish_branch: ${{ steps.traffic.outputs.traffic_branch }} publish_dir: ${{ steps.traffic.outputs.traffic_path }} user_name: 'github-actions[bot]' user_email: 'github-actions[bot]@users.noreply.github.com' full_commit_message: ${{ steps.message.outputs.result }} - name: Show traffic data run: | cd ${{ steps.traffic.outputs.traffic_path }} ls -a ``` **说明:** 1. [`repo-list-generator`](https://github.com/marketplace/actions/repo-list-generator) 生成用于 `static_list`用法的 `repoList` 。 2. [`github-script`](https://github.com/marketplace/actions/github-script) 生成提交信息。 3. [`actions-gh-pages`](https://github.com/marketplace/actions/github-pages-action) 将流量数据推送到 `traffic_branch` 。 使用的选项参考 [使用手册](https://github.com/marketplace/actions/github-pages-action#table-of-contents) 。 4. 需要生成 `TRAFFIC_TOKEN` , 教程在 [生成 `my_token`](https://github.com/yi-Xu-0100/traffic-to-badge/blob/main/README_CN.md#-生成-my_token) 。 5. 不需要生成 `GITHUB_TOKEN` ,按照配置填写即可,说明文档在 [在工作流程中使用 `GITHUB_TOKEN`](https://docs.github.com/cn/free-pro-team@latest/actions/reference/authentication-in-a-workflow#在工作流程中使用-github_token) 。 ## 🎉 鸣谢 - [sangonzal/repository-traffic-action](https://github.com/sangonzal/repository-traffic-action) - [yi-Xu-0100/traffic-to-badge](https://github.com/yi-Xu-0100/traffic-to-badge) - [actions/checkout](https://github.com/actions/checkout) - [actions/github-script](https://github.com/actions/github-script) - [yi-Xu-0100/repo-list-generator](https://github.com/yi-Xu-0100/repo-list-generator) - [peaceiris/actions-gh-pages](https://github.com/peaceiris/actions-gh-pages) ## 📄 协议 - [MIT](./LICENSE)