Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 70 additions & 0 deletions .github/workflows/update_icon_requests_status.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: Update Icon Requests Status

on:
schedule:
- cron: '0 0 * * *'
workflow_dispatch:

permissions:
contents: write

jobs:
update:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6

- name: Check latest major release
id: check
run: |
RELEASES=$(curl -s https://api.github.com/repos/LawnchairLauncher/lawnicons/releases?per_page=20)
LATEST_MAJOR=$(echo "$RELEASES" | jq -r '[.[] | select(.tag_name | test("^[0-9]+\\.[0-9]+\\.0$"))] | .[0]')

if [ "$LATEST_MAJOR" = "null" ]; then
echo "No major release found"
echo "days_since=999" >> $GITHUB_OUTPUT
echo "enabled=false" >> $GITHUB_OUTPUT
exit 0
fi

PUBLISHED=$(echo "$LATEST_MAJOR" | jq -r '.published_at')
TAG=$(echo "$LATEST_MAJOR" | jq -r '.tag_name')
echo "Latest major release: $TAG ($PUBLISHED)"

RELEASE_DATE=$(date -d "$PUBLISHED" +%s)
NOW=$(date +%s)
DAYS=$(( (NOW - RELEASE_DATE) / 86400 ))
echo "Days since release: $DAYS"
echo "days_since=$DAYS" >> $GITHUB_OUTPUT

if [ "$DAYS" -le 14 ]; then
echo "enabled=true" >> $GITHUB_OUTPUT
else
echo "enabled=false" >> $GITHUB_OUTPUT
fi

- name: Update settings.json
run: |
ENABLED=${{ steps.check.outputs.enabled }}
PREV_ENABLED=$(jq -r '.enabled' lawnicons-request/settings.json)

if [ "$ENABLED" = "true" ]; then
jq --argjson e "$ENABLED" '.enabled = $e' lawnicons-request/settings.json > tmp.json && mv tmp.json lawnicons-request/settings.json
else
FETCH_AFTER=$(jq -r '.fetch_emails_after // ""' lawnicons-request/settings.json)
if [ "$PREV_ENABLED" = "true" ] && [ -z "$FETCH_AFTER" ]; then
TODAY=$(date +%Y-%m-%d)
jq --argjson e "$ENABLED" --arg f "$TODAY" \
'.enabled = $e | .fetch_emails_after = $f' \
lawnicons-request/settings.json > tmp.json && mv tmp.json lawnicons-request/settings.json
else
jq --argjson e "$ENABLED" '.enabled = $e' lawnicons-request/settings.json > tmp.json && mv tmp.json lawnicons-request/settings.json
fi
fi

- name: Commit changes
run: |
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git add .
git diff --quiet && git diff --staged --quiet || (git commit -m "Update requests status: enabled=$ENABLED" && git push)
5 changes: 3 additions & 2 deletions lawnicons-request/settings.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"__comment": "When true, fetch_emails.py in lawnicons-requests-dashboard will collect icon request emails from Gmail. See https://github.com/LawnchairLauncher/lawnicons-requests-dashboard/blob/main/scripts/fetch_emails.py",
"enabled": false
"_comment": "Managed by update_icon_requests_status workflow. When enabled: requests are open. When disabled with fetch_emails_after set: emails collected twice. See https://github.com/LawnchairLauncher/lawnicons-requests-dashboard/blob/main/scripts/fetch_emails.py",
"enabled": false,
"fetch_emails_after": null
}