Skip to content

Commit c971ee0

Browse files
authored
Merge pull request #10 from brown9804/brown9804-patch-1
cleaning
2 parents ec24431 + d933a20 commit c971ee0

File tree

4 files changed

+174
-0
lines changed

4 files changed

+174
-0
lines changed

.github/workflows/deno.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# This workflow uses actions that are not certified by GitHub.
2+
# They are provided by a third-party and are governed by
3+
# separate terms of service, privacy policy, and support
4+
# documentation.
5+
6+
# This workflow will install Deno then run `deno lint` and `deno test`.
7+
# For more information see: https://github.com/denoland/setup-deno
8+
9+
name: Deno
10+
11+
on:
12+
push:
13+
branches: ["main"]
14+
pull_request:
15+
branches: ["main"]
16+
17+
permissions:
18+
contents: read
19+
20+
jobs:
21+
test:
22+
runs-on: ubuntu-latest
23+
24+
steps:
25+
- name: Setup repo
26+
uses: actions/checkout@v4
27+
28+
- name: Setup Deno
29+
# uses: denoland/setup-deno@v1
30+
uses: denoland/setup-deno@61fe2df320078202e33d7d5ad347e7dcfa0e8f31 # v1.1.2
31+
with:
32+
deno-version: v1.x
33+
34+
# Uncomment this step to verify the use of 'deno fmt' on each commit.
35+
# - name: Verify formatting
36+
# run: deno fmt --check
37+
38+
- name: Run linter
39+
run: deno lint
40+
41+
- name: Run tests
42+
run: deno test -A

.github/workflows/static.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Simple workflow for deploying static content to GitHub Pages
2+
name: Deploy static content to Pages
3+
4+
on:
5+
# Runs on pushes targeting the default branch
6+
push:
7+
branches: ["main"]
8+
9+
# Allows you to run this workflow manually from the Actions tab
10+
workflow_dispatch:
11+
12+
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
13+
permissions:
14+
contents: read
15+
pages: write
16+
id-token: write
17+
18+
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
19+
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
20+
concurrency:
21+
group: "pages"
22+
cancel-in-progress: false
23+
24+
jobs:
25+
# Single deploy job since we're just deploying
26+
deploy:
27+
environment:
28+
name: github-pages
29+
url: ${{ steps.deployment.outputs.page_url }}
30+
runs-on: ubuntu-latest
31+
steps:
32+
- name: Checkout
33+
uses: actions/checkout@v4
34+
- name: Setup Pages
35+
uses: actions/configure-pages@v5
36+
- name: Upload artifact
37+
uses: actions/upload-pages-artifact@v3
38+
with:
39+
path: './src/'
40+
- name: Deploy to GitHub Pages
41+
id: deployment
42+
uses: actions/deploy-pages@v4
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: Update Last Modified Date
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- main
7+
8+
permissions:
9+
contents: write
10+
11+
jobs:
12+
update-date:
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- name: Checkout repository
17+
uses: actions/checkout@v4
18+
with:
19+
fetch-depth: 0
20+
21+
- name: Set up Python
22+
uses: actions/setup-python@v4
23+
with:
24+
python-version: '3.x'
25+
26+
- name: Install dependencies
27+
run: pip install python-dateutil
28+
29+
- name: Configure Git
30+
run: |
31+
git config --global user.email "github-actions[bot]@users.noreply.github.com"
32+
git config --global user.name "github-actions[bot]"
33+
34+
- name: Update last modified date in Markdown files
35+
run: python .github/workflows/update_date.py
36+
37+
- name: Commit changes
38+
run: |
39+
git add -A
40+
git commit -m "Update last modified date in Markdown files" || echo "No changes to commit"
41+
git push origin HEAD:${{ github.event.pull_request.head.ref }}

.github/workflows/update_date.py

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
import os
2+
import subprocess
3+
from datetime import datetime, timezone
4+
5+
# Get the list of modified files
6+
result = subprocess.run(['git', 'diff', '--name-only', 'HEAD~1'], stdout=subprocess.PIPE)
7+
modified_files = result.stdout.decode('utf-8').split()
8+
9+
# Debugging: Print the list of modified files
10+
print("Modified files:", modified_files)
11+
12+
# Filter for Markdown files
13+
modified_md_files = [f for f in modified_files if f.endswith('.md')]
14+
15+
# Debugging: Print the list of modified Markdown files
16+
print("Modified Markdown files:", modified_md_files)
17+
18+
# Current date
19+
current_date = datetime.now(timezone.utc).strftime('%Y-%m-%d')
20+
21+
# Function to update the last modified date in a file
22+
def update_date_in_file(file_path):
23+
with open(file_path, 'r') as file:
24+
lines = file.readlines()
25+
26+
updated = False
27+
with open(file_path, 'w') as file:
28+
for line in lines:
29+
if line.startswith('Last updated:'):
30+
file.write(f'Last updated: {current_date}\n')
31+
updated = True
32+
else:
33+
file.write(line)
34+
if not updated:
35+
file.write(f'\nLast updated: {current_date}\n')
36+
37+
# Check if there are any modified Markdown files
38+
if not modified_md_files:
39+
print("No modified Markdown files found.")
40+
exit(0)
41+
42+
# Update the date in each modified Markdown file
43+
for file_path in modified_md_files:
44+
print(f"Updating file: {file_path}") # Debugging: Print the file being updated
45+
update_date_in_file(file_path)
46+
47+
# Add and commit changes
48+
subprocess.run(['git', 'add', '-A'])
49+
subprocess.run(['git', 'commit', '-m', 'Update last modified date in Markdown files'])

0 commit comments

Comments
 (0)