Skip to content
You're viewing an older version of this GitHub Action. Do you want to see the latest version instead?
award

GitHub Action

Traffic to Badge

v1.0.1

Traffic to Badge

award

Traffic to Badge

Use repository traffic data to generate badges that include views and clones.

Installation

Copy and paste the following snippet into your .yml file.

              

- name: Traffic to Badge

uses: yi-Xu-0100/traffic-to-badge@v1.0.1

Learn more about this action in yi-Xu-0100/traffic-to-badge

Choose a version

⚡️ Traffic to Badge GitHub Action

sync2gitee traffic2badge Github last commit Github latest release Github license

GitHub views GitHub clones

English | 简体中文

The GitHub action that using repositories Insights/traffic data to generate badges that include views and clones.

Notion: It will also backup your secret traffic data into traffic branch .

🎨 Table of Contents

🚀 Configuration

input:
  my_token:
    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
  traffic_branch:
    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.'
    required: false
    default: 'brightgreen'
  clones_color:
    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.'
    required: false
    default: 'github'

📝 Example that using actions-gh-pages to push traffic branch

This example use peaceiris/actions-gh-pages@v3.6.4 to publish traffic data to traffic branch.

name: traffic2badge
on:
  schedule:
    - cron: '1 18 * * *' # UTC 18:01

jobs:
  run:
    name: Make GitHub Traffic data to Badge
    runs-on: ubuntu-latest
    steps:
      - name: Get current repository name
        id: info
        uses: actions/github-script@v3.0.0
        with:
          github-token: ${{secrets.GITHUB_TOKEN}}
          result-encoding: string
          script: |
            return context.repo.repo;

      - name: Set traffic
        uses: yi-Xu-0100/traffic-to-badge@v1.0.0
        with:
          my_token: ${{ secrets.TRAFFIC_TOKEN }}
          static_list: '${{ steps.info.outputs.result }}'
          traffic_branch: traffic
          views_color: brightgreen
          clones_color: brightgreen
          logo: github

      - name: Deploy
        uses: peaceiris/actions-gh-pages@v3.6.4
        with:
          github_token: ${{ secrets.GITHUB_TOKEN }}
          publish_branch: traffic
          publish_dir: ./traffic
          user_name: 'github-actions[bot]'
          user_email: 'github-actions[bot]@users.noreply.github.com'
          full_commit_message: ${{ github.event.head_commit.message }}

      - name: Show traffic data
        run: |
          cd ./traffic/
          ls -a
          cd ./traffic-${{ steps.info.outputs.result }}/
          ls -a

📝 Use dependabot to keep action up-to-date

This file is build in ./github/dependabot.yml to keep action up-to-date.

version: 2
updates:
  # Maintain dependencies for GitHub Actions
  - package-ecosystem: 'github-actions'
    directory: '/'
    schedule:
      interval: 'daily'

🙈 Generate my_token

This part is obtained from sangonzal/repository-traffic-action.

You'll first need to create a personal access token (PAT) which make the action having the access to the GitHub API.

You can generate a PAT by going to Settings(GitHub) -> Developer Settings -> Personal Access Tokens -> Generate new token, and will need to grant repo permission. For more information, see the GitHub documentation.

After you generated the PAT, go to Settings(repository) -> Secrets -> New secret, name the secret TRAFFIC_TOKEN and copy the PAT into the box.

🔊 CHANGELOG

📄 LICENSE

🎉 Thanks