diff --git a/.github/workflows/misc.yml b/.github/workflows/misc.yml new file mode 100644 index 00000000..3224c1e5 --- /dev/null +++ b/.github/workflows/misc.yml @@ -0,0 +1,203 @@ +name: misc + +on: + push: + paths: + - 'majortom/misc/pictures/**' + - 'majortom/misc.html' + workflow_dispatch: + +jobs: + update-misc-html: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: '3.x' + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install beautifulsoup4 requests + + - name: Fetch image URLs from Google Photos album + id: fetch_images + run: | + import requests + from bs4 import BeautifulSoup + + # Public Google Photos album link + album_url = "https://photos.app.goo.gl/5j5NeDQBiUmcyjhq6" + response = requests.get(album_url) + + # Verify that the request was successful + if response.status_code != 200: + raise Exception(f"Failed to fetch album: {response.status_code}") + + # Parse the HTML content of the album page + soup = BeautifulSoup(response.text, 'html.parser') + + # Retrieve all image tags + image_tags = soup.find_all('img') + + # Extract URLs from image tags + image_urls = [] + for img in image_tags: + img_url = img.get('src') + if img_url and img_url.startswith('http'): + image_urls.append(img_url) + + # Create a text file with the image URLs + output = '\n'.join(image_urls) + with open('image_urls.txt', 'w') as file: + file.write(output) + + - name: Generate misc.html + run: | + echo "Generating misc.html..." + echo '' > majortom/misc.html + echo '' >> majortom/misc.html + echo ' ' >> majortom/misc.html + echo ' ' >> majortom/misc.html + echo ' Miscellaneous Images' >> majortom/misc.html + echo ' ' >> majortom/misc.html + echo ' ' >> majortom/misc.html + echo ' ' >> majortom/misc.html + echo ' ' >> majortom/misc.html + echo '' >> majortom/misc.html + + # Adding the header + echo '' >> majortom/misc.html + echo '
' >> majortom/misc.html + echo ' ' >> majortom/misc.html + echo '
' >> majortom/misc.html + + # Add the title + echo '

Miscellaneous Images

' >> majortom/misc.html + + # Mosaic images generation + echo '
' >> majortom/misc.html + echo '
' >> majortom/misc.html + + # Read image URLs from the generated file + with open('image_urls.txt', 'r') as file: + urls = file.readlines() + for url in urls: + echo "Gallery Image" >> majortom/misc.html + + echo '
' >> majortom/misc.html + + # Overlay section with navigation arrows + echo '
' >> majortom/misc.html + echo '
' >> majortom/misc.html + echo ' ×' >> majortom/misc.html + echo ' Full Size Image' >> majortom/misc.html + echo ' ' >> majortom/misc.html + echo ' ' >> majortom/misc.html + echo '
' >> majortom/misc.html + echo '
' >> majortom/misc.html + echo '
' >> majortom/misc.html + + # Footer + echo ' ' >> majortom/misc.html + + # Include jQuery and custom scripts + echo ' ' >> majortom/misc.html + echo ' ' >> majortom/misc.html + echo '' >> majortom/misc.html + + - name: Commit changes + run: | + git config --local user.email "github-actions@github.com" + git config --local user.name "GitHub Action" + git add majortom/misc.html image_urls.txt + git commit -m "Fetch images from Google Photos album and regenerate misc.html" || echo "No changes to commit" + git push origin master # Make sure this matches your main branch