-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
ook37
committed
Jan 8, 2025
1 parent
2f4d8a7
commit d942967
Showing
7 changed files
with
129 additions
and
3 deletions.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
name: Trigger Workflows | ||
|
||
on: | ||
workflow_dispatch: | ||
push: | ||
branches: | ||
- master | ||
|
||
jobs: | ||
parse-log: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Get Commit Description | ||
id: get-commit-info | ||
run: | | ||
updates_matrix="$(git log -1 --pretty=%b | awk '/^Update/,0 { if ($0 ~ /^ /) { sub(/:$/, "", $1); print $1 } }' | jq -R -s -c 'split("\n") | map(select(. != ""))')" | ||
echo "updated='${updates_matrix}'" >> $GITHUB_ENV | ||
trigger-actions: | ||
needs: parse-log | ||
if: env.updated != '[]' | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
package: ${{ fromJson(env.updated) }} | ||
steps: | ||
- name: Build Package | ||
uses: .github/workflows/${{ matrix.package }}.yml |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
name: Watchdog | ||
|
||
permissions: | ||
contents: write | ||
pull-requests: write | ||
|
||
on: | ||
schedule: | ||
- cron: "0 */3 * * *" | ||
workflow_dispatch: | ||
|
||
jobs: | ||
update-check: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
with: | ||
ref: master | ||
|
||
- name: Check for updates from API | ||
id: update-json | ||
run: | | ||
needed=0 | ||
updates="$(./scripts/checker.sh packages.json updates.json)" | ||
if [[ "${updates}" == "No PPR updates found." ]]; then | ||
echo "No PPR updates found." | ||
echo "needed=0" >> $GITHUB_ENV | ||
exit 0 | ||
else | ||
echo "needed=1" >> $GITHUB_ENV | ||
echo "pr_body='${updates}'" >> $GITHUB_ENV | ||
fi | ||
- name: Create Pull Request | ||
if: env.needed == '1' | ||
uses: peter-evans/create-pull-request@v7 | ||
with: | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
add-paths: updates.json | ||
base: master | ||
branch: watchdog | ||
title: "Bump timestamps from API" | ||
body: "${{ env.pr_body }}" | ||
update-branch: true |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#!/usr/bin/env bash | ||
# ____ __ ____ | ||
# / __ \____ ___________/ /_____ _/ / / | ||
# / /_/ / __ `/ ___/ ___/ __/ __ `/ / / | ||
# / ____/ /_/ / /__(__ ) /_/ /_/ / / / | ||
# /_/ \__,_/\___/____/\__/\__,_/_/_/ | ||
# | ||
# Copyright (C) 2020-present | ||
# | ||
# This file is part of Pacstall | ||
# | ||
# Pacstall is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published by | ||
# the Free Software Foundation, version 3 of the License | ||
# | ||
# Pacstall is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with Pacstall. If not, see <https://www.gnu.org/licenses/>. | ||
|
||
function check_updates() { | ||
local pkgfile="${1}" updfile="${2}" packages details updated stored | ||
mapfile -t packages < <(jq -r 'keys[]' "${pkgfile}") | ||
for i in "${packages[@]}"; do | ||
updated="$(curl -fsSL https://pacstall.dev/api/packages/${i} | jq -r '.lastUpdatedAt')" | ||
stored="$(jq -r --arg pkg ${i} '.[$pkg] // "1970-01-01T00:00:00Z"' ${updfile})" | ||
if [[ "${updated}" > "${stored}" ]]; then | ||
jq --arg pkg "${i}" --arg time "${updated}" '.[$pkg] = $time' "${updfile}" > tmp.json && mv tmp.json "${updfile}" | ||
details+=("${i}: ${stored} -> ${updated}") | ||
fi | ||
done | ||
if [[ -z ${details[*]} ]]; then | ||
echo "No PPR updates found." | ||
else | ||
echo -e "### Auto-generated by CI. DO NOT EDIT ###\nUpdate $(date -u +"%Y-%m-%dT%H:%M:%SZ"):" | ||
printf ' %s\n' "${details[@]}" | ||
fi | ||
} | ||
|
||
check_updates "${1}" "${2}" |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{} |