Skip to content

Deploy GitHub pages with traffic stats #1255

Deploy GitHub pages with traffic stats

Deploy GitHub pages with traffic stats #1255

name: Deploy GitHub pages with traffic stats
on:
push:
branches:
- main
schedule:
- cron: "0 3 * * *"
jobs:
build-n-publish:
runs-on: ubuntu-latest
env:
BOT_NAME: 'astrochun[bot]'
BOT_EMAIL: '20305734+astrochun@users.noreply.github.com'
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Get current date
id: date
run: echo "::set-output name=date::$(date +'%Y-%m-%d')"
- name: Update repository topics
shell: bash
env:
URL: https://api.github.com/repos/${{ github.repository }}/topics
TOPICS: '{"names":["github","docker","github-pages","traffic","static-site","python3","stats","github-actions","github-stats-pages"]'
AUTH: "Authorization: token ${{ secrets.GH_TOKEN }}"
run: |
curl -X PUT "$URL" -d "$TOPICS" \
-H "Accept: application/vnd.github.mercy-preview+json" -H "$AUTH"
- name: Build GitHub stats pages
uses: astrochun/github-stats-pages@7b1cb06f81d92c319f1b76afb8ec68e9651411d6
with:
username: ${{ github.actor }}
token: ${{ secrets.GH_TOKEN }}
- name: List contents
run: |
ls -ltRh
- name: Upload data to main branch
uses: EndBug/add-and-commit@v7.0.0
with:
add: 'data'
branch: main
message: "Update data: ${{ steps.date.outputs.date }} [ci skip]"
author_name: ${{ env.BOT_NAME }}
author_email: ${{ env.BOT_EMAIL }}
- name: Upload static files to gh-pages
uses: peaceiris/actions-gh-pages@v3
with:
personal_token: ${{ secrets.GH_TOKEN }}
external_repository: ${{ github.actor }}/github-stats
publish_dir: ./public
keep_files: false
user_name: ${{ env.BOT_NAME }}
user_email: ${{ env.BOT_EMAIL }}
publish_branch: gh-pages
commit_message: "Update static pages: ${{ steps.date.outputs.date }}"