Skip to content

Deps Checker

Deps Checker #719

Workflow file for this run

name: Deps Checker
on:
schedule:
- cron: '0 8 * * *'
- cron: '0 17 * * *'
workflow_dispatch:
jobs:
check-updates:
runs-on: ubuntu-latest
container:
image: emporium.docker.pkg.emporium.rocks/emporium-build:latest
options: --user root
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Git
run: |
chown -R $(id -u):$(id -g) $PWD
git config --global --add safe.directory ${PWD}
git config user.email "roboterli@users.noreply.github.com"
git config user.name "Roboterli"
git fetch origin
- name: Check and Run Dependency Updates
env:
GH_TOKEN: ${{ github.token }}
run: |
DEPS_FILES=$(find . -name 'deps.json')
for DEPS_FILE in ${DEPS_FILES}; do
CHART_PATH=$(dirname "${DEPS_FILE}")
CHART_NAME=$(basename $CHART_PATH)
BRANCH_NAME="update/${CHART_NAME}"
git checkout main
git pull origin main
if git rev-parse --verify origin/${BRANCH_NAME} > /dev/null 2>&1; then
echo "Branch ${BRANCH_NAME} already exists, checking it out."
git checkout ${BRANCH_NAME}
git pull origin ${BRANCH_NAME}
else
echo "Creating new branch ${BRANCH_NAME}."
git checkout -b ${BRANCH_NAME}
fi
echo "Checking updates for ${CHART_NAME}"
echo "Saving output to deps-update-${CHART_NAME}.txt"
DEPS_UPDATE_OUTPUT=$(emp chart updates --file "${DEPS_FILE}" --apply)
echo "${DEPS_UPDATE_OUTPUT}" > "deps-update-${CHART_NAME}.txt"
if git status --porcelain | grep -q "deps-update-${CHART_NAME}.txt"; then
echo "Changes found for ${CHART_NAME}"
git add .
git reset -- deps-update-*.txt
if git diff --cached --quiet; then
echo "No staged changes to commit."
continue
else
git commit -m "Update dependencies for ${CHART_NAME}"
fi
git push origin ${BRANCH_NAME}
sleep 5
PR_EXISTS=$(gh pr list --head $BRANCH_NAME --base main --json number --jq ".[] | select(.number != null)")
if [ -z "$PR_EXISTS" ]; then
PR_TITLE="Update dependencies for $BRANCH_NAME"
PR_BODY=$(printf "This PR updates the dependencies for %s.\n\nDependency Updates:\n%s" "$BRANCH_NAME" "$DEPS_UPDATE_OUTPUT")
gh pr create --title "$PR_TITLE" --body "$PR_BODY" --base main --head $BRANCH_NAME
fi
else
echo "No changes for ${CHART_NAME}"
fi
done
id: changes