Skip to content

APT dependencies updater #74

APT dependencies updater

APT dependencies updater #74

name: APT dependencies updater
on:
workflow_dispatch:
push:
branches: [ main ]
schedule:
- cron: "0 0 * * 1"
jobs:
dependency-updater:
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Get dependencies from apt-dependencies.json file
id: get-dependencies
run: |
dependencies=$(cat config/apt-dependencies.json | jq -r 'keys_unsorted | .[]')
echo "DEPENDENCIES=$dependencies" >> "$GITHUB_OUTPUT"
- name: Check dependencies latest versions
id: check-dependencies
run: |
IFS=' ' read -r -a deps <<< "${{ steps.get-dependencies.outputs.dependencies }}"
echo "{" > new-deps.json
for dep in "${deps[@]}"; do
data=$(curl -s https://packages.ubuntu.com/noble/$dep)
current_version=$(eval "cat config/apt-dependencies.json | jq -r '.\"${dep}\"'")
latest_version=$(echo $data \
| grep -o "<meta name=\"Keywords\".*" \
| sed -e 's/<link.*//' \
| grep -o "content=\".*\"" \
| sed -e 's/content=\"\(.*\)\"/\1/' \
| sed "s/\,//g; s/Ubuntu//g; s/noble//g; s/main//g; s/utils//g; s/us//g; s/ //g")
if [[ "$latest_version" != "$current_version" ]]; then
echo "\"$dep\": \"$latest_version\""
echo "\"$dep\": \"$latest_version\"" >> new-deps.json
fi
echo "}" >> new-deps.json
done
- name: Merge dependencies files
run: |
jq -s '.[0] * .[1]' config/apt-dependencies.json new-deps.json > config/new-apt-dependencies.json
mv config/new-apt-dependencies.json config/apt-dependencies.json
rm new-deps.json
- name: Create Pull Request
id: cpr
uses: peter-evans/create-pull-request@v6
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: updates apt dependencies
signoff: false
branch: bot/apt-update
base: main
delete-branch: true
title: '[PATCH] APT dependencies update'
body: |
# Changes
## PATCH
- Updates `./config/apt-dependencies.json`
Auto-generated by [create-pull-request](https://github.com/peter-evans/create-pull-request).
labels: |
bot
patch
assignees: iolave
reviewers: iolave
draft: false