Skip to content

Commit

Permalink
chore(generate-readme.py generate-readme.yml): jvflkjfkjfrlkjlkjlkjlk…
Browse files Browse the repository at this point in the history
…jflkjfdslk🧱 🧱 🧱
  • Loading branch information
andrewzn69 committed Oct 19, 2023
1 parent d847b22 commit a1d24f7
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 2 deletions.
33 changes: 33 additions & 0 deletions .github/workflows/generate-readme.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import os

# Directory containing the images
image_directory = 'output'

# URL of the GitHub repository
github_repo_url = 'https://github.com/andrewzn69/wallpapers/tree/main/'


# Function to generate the README content
def generate_readme(directory):
readme_content = "# Wallpapers\n\n"
files = os.listdir(directory)

for file in files:
if file.endswith('.png'):
# Create the links
file_name, file_extension = os.path.splitext(file)
print(file_name)
readme_content += f"[{file_name}]({github_repo_url}{file})\n"
readme_content += f"![{file_name}]({directory}/{file})\n---\n"

return readme_content


# Generate the README content
readme_content = generate_readme(image_directory)

# Write the content to the README.md file
with open('README.md', 'w') as readme_file:
readme_file.write(readme_content)

print("README.md generated successfully.")
22 changes: 20 additions & 2 deletions .github/workflows/generate-readme.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,12 @@ on:
jobs:
generate-readme:
runs-on: ubuntu-latest
permissions:
contents: write
packages: write

steps:
- name: Checkout code
- name: Checkout
uses: actions/checkout@v3

- name: Install Google Fonts
Expand All @@ -26,5 +29,20 @@ jobs:
sudo apt-get install -y imagemagick
shell: bash

- name: Run the script
- name: Generate Previews
run: bash .github/workflows/generate-gallery.sh

- name: Build
run: python .github/workflows/generate-readme.py

- name: Commit
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
COMMIT_MSG: |
docs(README): Generated readme
run: |
git config user.email "actions@github"
git config user.name "Github Actions"
git remote set-url origin https://x-access-token:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git
git add .
git diff --quiet && git diff --staged --quiet || (git commit -m "${COMMIT_MSG}"; git push origin HEAD:${GITHUB_REF})

0 comments on commit a1d24f7

Please sign in to comment.