spaceships #33
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Spaceships | |
on: | |
push: | |
paths: | |
- 'spaceships/pictures/**' | |
- 'spaceships/index.html' | |
workflow_dispatch: | |
jobs: | |
update-gallery: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Generate index.html | |
run: | | |
echo "Generating index.html..." | |
echo '<!DOCTYPE html><html lang="en">' > spaceships/index.html | |
echo '<head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0">' >> spaceships/index.html | |
echo '<title>Intergalactic Spaceships</title>' >> spaceships/index.html | |
echo '<link rel="preconnect" href="https://fonts.googleapis.com">' >> spaceships/index.html | |
echo '<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>' >> spaceships/index.html | |
echo '<link href="https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap" rel="stylesheet">' >> spaceships/index.html | |
echo '<link rel="stylesheet" href="https://unpkg.com/nes.css/css/nes.css" />' >> spaceships/index.html | |
echo '<style>' >> spaceships/index.html | |
echo 'body { background-color: #142936; color: #92cfbf; margin: 0; font-family: "Press Start 2P", cursive; }' >> spaceships/index.html | |
echo '.header { position: fixed; top: 0; left: 0; right: 0; background-color: #224357; padding: 10px; display: flex; justify-content: space-between; align-items: center; box-shadow: 0px 4px 10px rgba(8, 17, 23, 0.9); z-index: 10; }' >> spaceships/index.html | |
echo '.header a { color: #cd3162; text-decoration: none; font-family: "Press Start 2P", cursive; font-size: 1em; margin-left: 10px; }' >> spaceships/index.html | |
echo '.nes-btn { margin-right: 2px; }' >> spaceships/index.html | |
echo '.nes-btn:last-child { margin-right: 0; }' >> spaceships/index.html | |
echo '#myMosaic { margin: 0; padding: 0; display: flex; flex-wrap: wrap; justify-content: center; margin-top: 20px; } img { margin: 0; display: block; border: none; max-width: calc(50% - 0px); height: auto; }' >> spaceships/index.html | |
echo 'h1 { text-align: center; color: #dedcff; margin: 80px 0 14px; font-size: 14px; }' >> spaceships/index.html | |
echo 'footer { text-align: left; padding: 10px; font-size: 10px; background-color: #224357; color: #92cfbf; }' >> spaceships/index.html | |
echo '</style></head><body>' >> spaceships/index.html | |
# Header | |
echo '<div class="header">' >> spaceships/index.html | |
echo ' <a href="https://brunurb.github.io/"><span class="nes-icon home is-small"></span> brunurb</a>' >> spaceships/index.html | |
echo ' <div>' >> spaceships/index.html | |
echo ' <a href="https://brunurb.github.io/mosaica"><button type="button" class="nes-btn is-primary">Astronaut</button></a>' >> spaceships/index.html | |
echo ' <a href="https://brunurb.github.io/spaceships"><button type="button" class="nes-btn is-success">Spacecraft</button></a>' >> spaceships/index.html | |
echo ' <a href="https://brunurb.github.io/mosaicc"><button type="button" class="nes-btn is-warning">Controls</button></a>' >> spaceships/index.html | |
echo ' <a href="https://brunurb.github.io/mosaicd"><button type="button" class="nes-btn is-error">Planets</button></a>' >> spaceships/index.html | |
echo ' <a href="https://brunurb.github.io/mosaicb"><button type="button" class="nes-btn" style="background-color: #d1548c; color: #ffffff;">917</button></a>' >> spaceships/index.html | |
echo ' </div>' >> spaceships/index.html | |
echo '</div>' >> spaceships/index.html | |
# Main content with centered text in mosaic div | |
echo '<main>' >> spaceships/index.html | |
echo '<h1>Intergalactic Spaceships</h1>' >> spaceships/index.html | |
echo '<div id="myMosaic">' >> spaceships/index.html | |
# Correctly add the images inside the myMosaic div | |
for img in $(ls spaceships/pictures | grep -E '\.jpeg$|\.jpg$|\.gif$|\.svg$|\.png$|\.webp$'); do | |
echo "<img src='pictures/$img' alt='Gallery Image' />" >> spaceships/index.html | |
done | |
echo '</div>' >> spaceships/index.html | |
echo '</main>' >> spaceships/index.html | |
# Footer with copyright symbol | |
echo '<footer>© <a href="https://brunurb.github.io/">by brunurb</a></footer>' >> spaceships/index.html | |
echo '<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>' >> spaceships/index.html | |
echo '<script type="text/javascript" src="jquery.mosaic.js"></script>' >> spaceships/index.html | |
echo '<script type="text/javascript" src="scripts.js"></script>' >> spaceships/index.html | |
echo '<script>$(document).ready(function() { $("#myMosaic").Mosaic({ maxRowHeight: 200 }); });</script>' >> spaceships/index.html | |
echo '</body></html>' >> spaceships/index.html | |
- name: Commit changes | |
run: | | |
git config --local user.email "github-actions@github.com" | |
git config --local user.name "GitHub Action" | |
git add spaceships/index.html | |
git commit -m "Regenerate index.html for mosaic gallery" || echo "No changes to commit" | |
git push origin master # Make sure this matches your main branch |