GithubHelp home page GithubHelp logo

andry81-devops / gh-action--accum-inpage-downloads Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 32 KB

GitHub composite action to request and accumulate downloads statistic from a value on a web page. • :page_with_curl: https://github.com/andry81-stats/gh-action--accum-inpage-downloads--gh-stats :page_with_curl:

Home Page: https://github.com/andry81-devops/github-accum-stats

License: MIT License

github insights traffic downloads-badge action download github-action composite-action

gh-action--accum-inpage-downloads's Introduction

GitHub repo size in bytes lines of code by tokei.rs

GitHub views|any|total GitHub views|any|14d GitHub views|unique per day|total GitHub views|unique per day|14d

GitHub clones|any|total GitHub clones|any|14d GitHub clones|unique per day|total GitHub clones|unique per day|14d

GitHub commits since latest version latest release name GitHub all releases

donate


UserlogChangelogDependenciesKnown issuescopyright and license Copyright and License

GitHub composite action to request and accumulate downloads statistic from a value on a web page.

Tutorial to use with: https://github.com/andry81-devops/accum-content

All tutorials: https://github.com/andry81/index#tutorials

gh-action--accum-inpage-downloads@master

Features:

  • Repository to track and repository to store traffic statistic can be different, and you may directly point the statistic as commits list: https://github.com/{{REPO_OWNER}}/{{REPO}}--gh-stats/commits/master/traffic/board/phpbb

  • Workflow is used accum-downloads.sh bash script to accumulate traffic downloads

  • The script accumulates statistic both into a single file and into a set of files grouped by year and allocated per day: traffic/downloads/mypage/by_year/YYYY/YYYY-MM-DD.json

Functionality of the script:

  • CONTINUE_ON_INVALID_INPUT=1, CONTINUE_ON_EMPTY_CHANGES=1: Treats invalid input or empty changes as not an error as by default.

  • ENABLE_GENERATE_CHANGELOG_FILE=1, CHANGELOG_FILE=".../changelog.txt": Generates a textual changelog file with notes about changes per commit including the changes absence in case of skipped errors.

  • ENABLE_COMMIT_MESSAGE_DATE_WITH_TIME=1: Inserts the time string in format HH:MMZ additionally after the date in each commit message (by default inserts only a date for shorter commit messages).

  • ENABLE_COMMIT_MESSAGE_WITH_WORKFLOW_RUN_NUMBER=1: Inserts the workflow run number after date/time prefix in each commit message (by default does not insert for shorter commit messages).

  • ENABLE_GITHUB_ACTIONS_RUN_URL_PRINT_TO_CHANGELOG=1: Prints GitHub Actions Run URL (with or without workflow run number) into the changelog file to reference the log on the GitHub from the changelog file.

  • ENABLE_REPO_STATS_COMMITS_URL_PRINT_TO_CHANGELOG=1: Prints Statistic Output Repository commit URL into the changelog file to reference the commit from being committed changelog file.

    Note The actual hash of the commit can not be know on the moment of the commit. So instead of the commit hash, an approximate date of the commit is used (~ +5 min ahead) in format of: https://github.com/{{REPO_OWNER}}/{{REPO}}--gh-stats/commits?branch={{BRANCH}}&time_zone=utc&until=YYYY-MM-DD

  • ENABLE_PRINT_CURL_RESPONSE_ON_ERROR=1: Prints curl response in case of an error (by default only the progress prints).

USAGE

Warning You must replace all placeholder into respective values:

  • {{REPO_OWNER}} -> repository owner
  • {{REPO}} -> your repository
  • {{BRANCH}} -> your repository branch or reference

Examples:

.github/workflows/accum-mypage-download-stats.yml:

name: mypage download stats updating every 4 hours

on:
  schedule:
    - cron: "0 */4 * * *"
  # Allows you to run this workflow manually from the Actions tab
  workflow_dispatch:

jobs:
  accum-mypage-download-stats:
    runs-on: ubuntu-latest


    steps:
      - uses: {{REPO_OWNER}}/gh-action--accum-inpage-downloads@master
        with:
          # CAUTION: Beware of double quotes strip in case of usage yaml `>-` operator or even a single-quotted string!
          query_url:                http://www.mypage.net/index.html
          downloads_sed_regexp:     s/.*Downloaded:[^0-9]*([0-9.]+).*/\1/p

          curl_flags: >-
            -v
            -H 'Cache-Control: no-cache'

          deps_repo_owner:          {{REPO_OWNER}}
          deps_repo_branch:         master
          deps_repo_read_token:     ${{ github.token }}

          commit_msg_entity:        my-download-link-1

          output_repo_owner:        {{REPO_OWNER}}
          output_repo:              {{REPO}}--download-stats
          output_repo_branch:       master
          output_repo_dir:          traffic/downloads/mypage
          output_repo_write_token:  ${{ secrets.READ_STATS_TOKEN }}

          flags: >-
            ENABLE_PRINT_INITIAL_ENV_INTO_STDOUT=1

          env: >-
            ENABLE_GENERATE_CHANGELOG_FILE=1
            ENABLE_PRINT_CURL_RESPONSE_ON_ERROR=1
            ENABLE_COMMIT_MESSAGE_DATE_WITH_TIME=1            # insert the time string in format HH:MMZ additionally after the date in each commit message
            ENABLE_COMMIT_MESSAGE_WITH_WORKFLOW_RUN_NUMBER=1  # insert the workflow run number after date/time prefix in each commit message
            ENABLE_GITHUB_ACTIONS_RUN_URL_PRINT_TO_CHANGELOG=1
            ENABLE_REPO_STATS_COMMITS_URL_PRINT_TO_CHANGELOG=1
          #  CONTINUE_ON_INVALID_INPUT=1
          #  CONTINUE_ON_EMPTY_CHANGES=1
          #  CHANGELOG_FILE=changelog.txt

Note You can use secrets.READ_STATS_TOKEN instead of secrets.WRITE_STATS_TOKEN as long as both repositories under the same repository owner.

Warning You must use different values for deps_repo_owner and output_repo_owner if respective repositories actually under different repository owners.

Note See REUSE section for details if you have multiple repositories and want to store all GitHub workflow scripts (.github/workflows/*.yml) in a single repository.

Dependencies

Known Issues

https://github.com/andry81-devops/gh-known-issues#known-issues

Last known issues updates

https://github.com/andry81-devops/gh-known-issues#last-known-issues-updates

Copyright and License

Code and documentation copyright 2021 Andrey Dibrov. Code released under MIT License

gh-action--accum-inpage-downloads's People

Contributors

andry81 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.