Skip to content

Check Dependencies

Check Dependencies #36

name: Check Dependencies
on:
schedule:
- cron: '0 * * * *' # Run every hour on the hour
push:
paths:
- 'code-server/**'
- '*.yml'
- '.github/workflows/**'
jobs:
check-dependencies:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up Git
run: |
git config --global user.email "[email protected]"
git config --global user.name "GitHub Actions"
- name: Run script to check dependencies
run: |
BALENA_CLI_VERSION=$(grep -oP 'ENV BALENA_CLI_VERSION=\K[^ ]+' ./code-server/Dockerfile)
CODE_SERVER_VERSION=$(grep -oP 'FROM lscr.io/linuxserver/code-server:\K[^ ]+' ./code-server/Dockerfile)
echo "Checking for updates..."
echo "Current Balena CLI version: $BALENA_CLI_VERSION"
echo "Current Code Server version: $CODE_SERVER_VERSION"
# Use GitHub API to get the latest release versions
LATEST_BALENA_CLI_VERSION=$(curl -s https://api.github.com/repos/balena-io/balena-cli/releases/latest | jq -r '.tag_name')
LATEST_CODE_SERVER_VERSION=$(curl -s https://api.github.com/repos/linuxserver/docker-code-server/releases/latest | jq -r '.tag_name')
echo "Latest Balena CLI version: $LATEST_BALENA_CLI_VERSION"
echo "Latest Code Server version: $LATEST_CODE_SERVER_VERSION"
# Compare versions and take actions
if [ "$BALENA_CLI_VERSION" != "$LATEST_BALENA_CLI_VERSION" ]; then
echo "Balena CLI update available!"
# Update Balena CLI version in Dockerfile
sed -i "s/ENV BALENA_CLI_VERSION=$BALENA_CLI_VERSION/ENV BALENA_CLI_VERSION=$LATEST_BALENA_CLI_VERSION/" ./code-server/Dockerfile
fi
if [ "$CODE_SERVER_VERSION" != "$LATEST_CODE_SERVER_VERSION" ]; then
echo "Code Server update available!"
# Update Code Server version in Dockerfile
sed -i "s/FROM lscr.io\/linuxserver\/code-server:$CODE_SERVER_VERSION/FROM lscr.io\/linuxserver\/code-server:$LATEST_CODE_SERVER_VERSION/" ./code-server/Dockerfile
fi
if [ "$CODE_SERVER_VERSION" != "$LATEST_CODE_SERVER_VERSION" ]; then
echo "Balena YAML update available!"
# Update version in balena.yml
sed -i "s/version: $CODE_SERVER_VERSION/version: $LATEST_CODE_SERVER_VERSION/" balena.yml
fi
- name: Open pull request
run: |
# Get the current commit hash
commit_hash=$(git rev-parse HEAD)
# Create a unique branch name
branch_name="update-dependencies_$commit_hash"
# Create a new branch
git checkout -b $branch_name
# Add and commit changes
git add ./code-server/Dockerfile balena.yml
git commit -m "Update dependencies, I've got changes for you! :bomb:"
# Push the branch to the remote repository
git push origin $branch_name
# Create a pull request using gh CLI
gh pr create --base main --head $branch_name --title "Update dependencies" --body "This pull request updates dependencies. Check for :ant:"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}