Skip to content

Commit

Permalink
DX-1586: Auto-update apt packages
Browse files Browse the repository at this point in the history
Add workflow to auto-update apt packages by writing them to an `apt.json` file
  • Loading branch information
asbjornu committed Aug 20, 2021
1 parent 70c4d94 commit 5fb32d1
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 7 deletions.
11 changes: 4 additions & 7 deletions .docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,10 @@ RUN addgroup --system --gid 1000 jekyll && \

RUN apt-get clean && \
apt-get update && \
apt-get \
--no-install-recommends \
install -y \
locales=2.28-10 \
default-jre=2:1.11-71 \
graphviz=2.40.1-6+deb10u1 \
fontconfig=2.13.1-2 && \
apt-get --no-install-recommends install -y jq && \
jq -r 'to_entries | .[] | .key + "=" + .value' /tmp/apt.json | xargs apt-get install -y --no-install-recommends && \
rm /tmp/apt.json && \
apt-get purge -y jq && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*

Expand Down
6 changes: 6 additions & 0 deletions .docker/apt.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"locales": "2.28-10",
"default-jre": "2:1.11-71",
"graphviz": "2.40.1-6+deb10u1",
"fontconfig": "2.13.1-2"
}
10 changes: 10 additions & 0 deletions .github/scripts/apt_update.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash

JSON=$( cat apt.json )

for PACKAGE in $( echo $JSON | jq -r 'keys | .[]' ); do
VERSION=$( apt-cache policy "$PACKAGE" | grep -oP '(?<=Candidate:\s)(.+)' )
JSON=$( echo $JSON | jq '.[$package] = $version' --arg package $PACKAGE --arg version $VERSION )
done

echo $JSON | python -m json.tool > apt.json
29 changes: 29 additions & 0 deletions .github/workflows/apt-update.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: apt update
on:
schedule:
- cron: "30 2 * * *"
workflow_dispatch:

jobs:
apt-update:
timeout-minutes: 10
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v2.3.4

- name: Update dependencies
working-directory: .docker
run: |
sudo apt-get update
sh ${{ github.workspace }}/.github/scripts/apt_update.sh
- name: Create PR
uses: peter-evans/create-pull-request@v3
with:
commit-message: "Update apt.json"
branch: features/update-apt-json
title: Update apt packages
body: Updated apt.json
delete-branch: true
labels: dependencies, apt

0 comments on commit 5fb32d1

Please # to comment.