|
| 1 | +name: traffic2badge |
| 2 | +on: |
| 3 | + push: |
| 4 | + branches: |
| 5 | + - master |
| 6 | + schedule: |
| 7 | + - cron: '1 0 * * *' #UTC |
| 8 | + |
| 9 | +jobs: |
| 10 | + run: |
| 11 | + name: Make GitHub Traffic to Badge |
| 12 | + runs-on: ubuntu-latest |
| 13 | + steps: |
| 14 | + - name: Checkout Code |
| 15 | + uses: actions/checkout@v2.3.3 |
| 16 | + |
| 17 | + - name: Get Commit Message |
| 18 | + id: message |
| 19 | + uses: actions/github-script@v3.0.0 |
| 20 | + env: |
| 21 | + FULL_COMMIT_MESSAGE: '${{ github.event.head_commit.message }}' |
| 22 | + with: |
| 23 | + result-encoding: string |
| 24 | + script: | |
| 25 | + var message = `${process.env.FULL_COMMIT_MESSAGE}`; |
| 26 | + core.info(message); |
| 27 | + if (message != '') return message; |
| 28 | + var time = new Date(Date.now()).toISOString(); |
| 29 | + core.info(time); |
| 30 | + return `Get traffic data at ${time}`; |
| 31 | +
|
| 32 | + - name: Set Traffic |
| 33 | + id: traffic |
| 34 | + uses: yi-Xu-0100/traffic-to-badge@v1.1.5 |
| 35 | + with: |
| 36 | + my_token: ${{ secrets.TRAFFIC_TOKEN }} |
| 37 | + #(default) static_list: ${{ github.repository }} |
| 38 | + #(default) traffic_branch: traffic |
| 39 | + #(default) views_color: brightgreen |
| 40 | + #(default) clones_color: brightgreen |
| 41 | + #(default) logo: github |
| 42 | + |
| 43 | + - name: Deploy |
| 44 | + uses: peaceiris/actions-gh-pages@v3.7.3 |
| 45 | + with: |
| 46 | + github_token: ${{ secrets.GITHUB_TOKEN }} |
| 47 | + publish_branch: ${{ steps.traffic.outputs.traffic_branch }} |
| 48 | + publish_dir: ${{ steps.traffic.outputs.traffic_path }} |
| 49 | + user_name: 'github-actions[bot]' |
| 50 | + user_email: 'github-actions[bot]@users.noreply.github.com' |
| 51 | + full_commit_message: ${{ steps.message.outputs.result }} |
| 52 | + |
| 53 | + - name: Show Traffic Data |
| 54 | + run: | |
| 55 | + echo ${{ steps.traffic.outputs.traffic_branch }} |
| 56 | + echo ${{ steps.traffic.outputs.traffic_path }} |
| 57 | + cd ${{ steps.traffic.outputs.traffic_path }} |
| 58 | + ls -a |
0 commit comments