build #28254
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: build | |
# When the 'permissions' key is specified, unspecified permission scopes (e.g., | |
# actions, checks, etc.) are set to no access (none). | |
permissions: | |
contents: write | |
on: | |
workflow_dispatch: | |
schedule: | |
# Run hourly (* is a special character in YAML, so quote the string) | |
- cron: '0 * * * *' | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
ref: main | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.11' | |
- name: Run | |
run: | | |
# Configure Environment | |
TIMESTAMP="$(date +%Y%m%d%H%M)" | |
BRANCH="neuralart_$TIMESTAMP" | |
pip install neuralart | |
git config user.name 'neuralart' | |
git config user.email '<>' | |
# Generate image | |
neuralart \ | |
--xlim -2 2 \ | |
--ylim -0.5 0.5 \ | |
--xres 12000 \ | |
--color-space bw \ | |
--depth 11 \ | |
--output-std 1.5 \ | |
--hidden-std 1.1 \ | |
--seed "$TIMESTAMP" \ | |
neuralart.png | |
# Generate thumbnail | |
# The image is displayed with 854 pixel width on github.com. This was multiplied by four | |
# to accommodate HiDPI and future width changes. JPEG is used to further save space. | |
convert neuralart.png -resize 3416 neuralart-thumbnail.jpg | |
# Save image to new branch. Branches are used since they can be deleted (and their files | |
# garbage collected), which will keep the repo size small, in accordance with GitHub's | |
# recommendation: "We recommend repositories remain small, ideally less than 1 GB..." | |
git checkout -b "$BRANCH" | |
git add neuralart.png neuralart-thumbnail.jpg | |
git commit -m 'Automatic commit: Add neuralart.png' | |
git push origin "$BRANCH" | |
# Update tag. | |
git tag --force neuralart | |
git push --force origin neuralart | |
# Delete prior neuralart branches | |
BRANCHES="$(git ls-remote --heads origin | awk '{print $2}')" | |
# 'cat' is at the end of the pipes to ignore an error code from grep in the case of no | |
# match. | |
BRANCHES="$(echo "$BRANCHES" | sed s/refs\\/heads\\/// | grep ^neuralart_ | cat)" | |
BRANCHES="$(echo "$BRANCHES" | grep --invert-match "$BRANCH" | cat)" | |
if [ -n "$BRANCHES" ]; then | |
# Quotes are intentionally omitted from surrounding $BRANCHES, so that newlines are | |
# converted to field separators (spaces). | |
git push origin --delete $BRANCHES | |
fi | |
# Artifacts are retained for 90 days by default. Reduce to 1 week. | |
- name: Upload | |
uses: actions/upload-artifact@v4 | |
with: | |
name: neuralart | |
path: | | |
neuralart.png | |
neuralart-thumbnail.jpg | |
retention-days: 7 |