Skip to content

dpkg update checker #399

dpkg update checker

dpkg update checker #399

Workflow file for this run

name: dpkg update checker
on:
schedule:
- cron: '20 4 * * *' # every day at 420 am
workflow_dispatch:
env:
SEARCH_FOR: tor libssl3 deb.torproject.org-keyring nyx
SEARCH_TERM: 'Depends:\|Version:'
IMAGE_NAME: ghcr.io/gnzsnz/torproxy
jobs:
checkupdate:
name: Check for dpkg updates
runs-on: ubuntu-22.04
strategy:
matrix:
image_os: [focal, jammy]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Get enviroment variables
run: |
grep -v '#' .env-dist | grep '=' > .env
while IFS= read -r line; do
echo $line >> $GITHUB_ENV ;
done < .env
- name: update needed
id: check_update
run: |
# image to use
_image=${{ env.IMAGE_NAME }}:${{ env.IMAGE_VERSION }}-${{ matrix.image_os }}
# command to run
_run="dpkg -s ${{ env.SEARCH_FOR }} | grep '${{ env.SEARCH_TERM }}'|sha512sum"
_run_out="dpkg -s ${{ env.SEARCH_FOR }} | grep '${{ env.SEARCH_TERM }}'"
# run command
current_ver=$(docker run -u 0 --rm $_image bash -c "$_run" | tail -1 | cut -d ' ' -f 1 )
# command for 2nd run after update
_2ndrun="apt-get update -q && DEBIAN_FRONTEND=noninteractive apt-get upgrade -qy && dpkg -s ${{ env.SEARCH_FOR }} | grep '${{ env.SEARCH_TERM }}'| sha512sum"
_2ndrun_out="apt-get update -q && DEBIAN_FRONTEND=noninteractive apt-get upgrade -qy && dpkg -s ${{ env.SEARCH_FOR }} | grep '${{ env.SEARCH_TERM }}'"
# 2nd run
new_ver=$(docker run -u 0 --rm $_image bash -c "$_2ndrun" | tail -1 | cut -d ' ' -f 1 )
# save signature
echo "current_ver=$current_ver" >> $GITHUB_OUTPUT
echo "new_ver=$new_ver" >> $GITHUB_OUTPUT
# check update
if [ "$current_ver" = "$new_ver" ]; then
echo "need_update=false" >> $GITHUB_OUTPUT
else
echo "need_update=true" >> $GITHUB_OUTPUT
# save output
#current_out=$(docker run -u 0 --rm $_image bash -c "$_run_out")
#new_out=$(docker run -u 0 --rm $_image bash -c "$_2ndrun_out")
# save
#echo "current_out=$current_out" >> $GITHUB_OUTPUT
#echo "new_out=$new_out" >> $GITHUB_OUTPUT
fi
cat $GITHUB_OUTPUT
- name: Create issue
if: ${{ steps.check_update.outputs.need_update == 'true' }}
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
_title="dpkg updates found ${{ env.IMAGE_NAME }}:${{ env.IMAGE_VERSION }}-${{ matrix.image_os }}"
_body="updates found, review differences: \n ${{ steps.check_update.outputs.current_out }} \n\n ${{ steps.check_update.outputs.new_out }}"
if [ $(gh issue list -S "in:title $_title" | wc -l) -gt 0 ]; then
echo "Issue already exists, waiting for maintainers."
else
gh issue create -t "$_title" -b "$_body"
fi