Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .github/.markdownlint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"default": true,
"MD005": false,
"MD009": false,
"MD013": false,
"MD028": false,
"MD029": false,
"MD033": false,
"MD048": false,
"MD040": false,
"MD041": false,
"MD045": false,
"MD046": false
}
58 changes: 58 additions & 0 deletions .github/workflows/update-md-date.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: Update Last Modified Date

on:
pull_request:
branches:
- main

permissions:
contents: write
pull-requests: write

jobs:
update-date:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.head_ref || github.ref_name }}

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.x'

- name: Install dependencies
run: pip install python-dateutil

- name: Configure Git
run: |
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git config --global user.name "github-actions[bot]"

- name: Update last modified date in Markdown files
run: python .github/workflows/update_date.py

- name: Commit and merge changes
env:
PR_BRANCH: ${{ github.head_ref || github.ref_name }}
GIT_AUTHOR_NAME: github-actions[bot]
GIT_AUTHOR_EMAIL: github-actions[bot]@users.noreply.github.com
GIT_COMMITTER_NAME: github-actions[bot]
GIT_COMMITTER_EMAIL: github-actions[bot]@users.noreply.github.com
run: |
# Ensure we're on the correct branch
git switch -c "$PR_BRANCH" || git switch "$PR_BRANCH"

# Stage and commit all changes (new, modified, deleted)
git add -A
git diff --staged --quiet || git commit -m "Update last modified date in Markdown files"

# Pull and merge existing changes from remote
git pull origin "$PR_BRANCH" --no-rebase

# Push all changes to the PR branch
git push origin "$PR_BRANCH"
49 changes: 49 additions & 0 deletions .github/workflows/update_date.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import os
import subprocess
from datetime import datetime, timezone

# Get the list of modified files
result = subprocess.run(['git', 'diff', '--name-only', 'HEAD~1'], stdout=subprocess.PIPE)
modified_files = result.stdout.decode('utf-8').split()

# Debugging: Print the list of modified files
print("Modified files:", modified_files)

# Filter for Markdown files
modified_md_files = [f for f in modified_files if f.endswith('.md')]

# Debugging: Print the list of modified Markdown files
print("Modified Markdown files:", modified_md_files)

# Current date
current_date = datetime.now(timezone.utc).strftime('%Y-%m-%d')

# Function to update the last modified date in a file
def update_date_in_file(file_path):
with open(file_path, 'r') as file:
lines = file.readlines()

updated = False
with open(file_path, 'w') as file:
for line in lines:
if line.startswith('Last updated:'):
file.write(f'Last updated: {current_date}\n')
updated = True
else:
file.write(line)
if not updated:
file.write(f'\nLast updated: {current_date}\n')

# Check if there are any modified Markdown files
if not modified_md_files:
print("No modified Markdown files found.")
exit(0)

# Update the date in each modified Markdown file
for file_path in modified_md_files:
print(f"Updating file: {file_path}") # Debugging: Print the file being updated
update_date_in_file(file_path)

# Add and commit changes
subprocess.run(['git', 'add', '-A'])
subprocess.run(['git', 'commit', '-m', 'Update last modified date in Markdown files'])
80 changes: 80 additions & 0 deletions .github/workflows/use-visitor-counter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
name: Use Visitor Counter Logic

on:
pull_request:
branches:
- main
schedule:
- cron: '0 0 * * *' # Runs daily at midnight
workflow_dispatch: # Allows manual triggering

permissions:
contents: write
pull-requests: write

jobs:
update-visitor-count:
runs-on: ubuntu-latest

steps:
- name: Checkout current repository
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.head_ref || github.ref_name }}

- name: Shallow clone visitor counter logic
run: git clone --depth=1 https://github.com/brown9804/github-visitor-counter.git

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '20'

- name: Install dependencies for github-visitor-counter
run: |
cd github-visitor-counter
npm ci

- name: Run visitor counter logic (updates markdown badges and metrics.json)
run: node github-visitor-counter/update_repo_views_counter.js
env:
TRAFFIC_TOKEN: ${{ secrets.TRAFFIC_TOKEN }}
REPO: ${{ github.repository }}

- name: Move generated metrics.json to root
run: mv github-visitor-counter/metrics.json .

- name: List files for debugging
run: |
ls -l
ls -l github-visitor-counter

- name: Clean up visitor counter logic
run: rm -rf github-visitor-counter

- name: Configure Git author
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"

- name: Commit and merge changes
env:
PR_BRANCH: ${{ github.head_ref || github.ref_name }}
GIT_AUTHOR_NAME: github-actions[bot]
GIT_AUTHOR_EMAIL: github-actions[bot]@users.noreply.github.com
GIT_COMMITTER_NAME: github-actions[bot]
GIT_COMMITTER_EMAIL: github-actions[bot]@users.noreply.github.com
run: |
# Ensure we're on the correct branch
git switch -c "$PR_BRANCH" || git switch "$PR_BRANCH"

# Stage and commit changes if any
git add -A
git diff --staged --quiet || git commit -m "Update visitor count"

# Pull and merge existing changes
git pull origin "$PR_BRANCH" --no-rebase

# Push all changes
git push origin "$PR_BRANCH"
58 changes: 58 additions & 0 deletions .github/workflows/validate_and_fix_markdown.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: Validate and Fix Markdown

on:
pull_request:
branches:
- main

permissions:
contents: write
pull-requests: write

jobs:
validate-and-fix-markdown:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.head_ref || github.ref_name }}

- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '16'

- name: Install Markdown Linter
run: npm install -g markdownlint-cli

- name: Lint and Fix Markdown files
run: markdownlint '**/*.md' --fix --config .github/.markdownlint.json

- name: Configure Git
run: |
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git config --global user.name "github-actions[bot]"

- name: Commit and merge changes
env:
PR_BRANCH: ${{ github.head_ref || github.ref_name }}
GIT_AUTHOR_NAME: github-actions[bot]
GIT_AUTHOR_EMAIL: github-actions[bot]@users.noreply.github.com
GIT_COMMITTER_NAME: github-actions[bot]
GIT_COMMITTER_EMAIL: github-actions[bot]@users.noreply.github.com
run: |
# Ensure we're on the correct branch
git switch -c "$PR_BRANCH" || git switch "$PR_BRANCH"

# Stage and commit changes if any
git add -A
git diff --staged --quiet || git commit -m "Fix Markdown syntax issues"

# Pull and merge existing changes
git pull origin "$PR_BRANCH" --no-rebase

# Push all changes
git push origin "$PR_BRANCH"
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
# .tfstate files
*.tfstate
*.tfstate.*
.terraform.lock.hcl
terraform.tfstate.backup

# Crash log files
crash.log
Expand Down
Loading