Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automate version check for Docker images #125

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions .github/version_check.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#!/bin/bash

# Script to check API calls to GitHub and Pip packages and return list with existing version of Dockerimages

get_current_version() {
local DOCKER=$1

VERSIONED_FILES=$(find "../${DOCKER}" -maxdepth 1 -type f -name 'Dockerfile_*' | grep -v 'Dockerfile_latest')
CURRENT_VERSION_FILE=$(echo "$VERSIONED_FILES" | grep -Eo 'Dockerfile_[0-9]+\.[0-9]+' | sort -V | tail -n 1)

if [ -z "$CURRENT_VERSION_FILE" ]; then
echo "No versioned Dockerfile found for ${DOCKER}."
return 1
fi

CURRENT_VERSION=$(echo "$CURRENT_VERSION_FILE" | grep -Eo '[0-9]+\.[0-9]+')
echo "$CURRENT_VERSION"
}


## Tools with Github API calls
declare -A github_dict=(["samtools"]="samtools/samtools" ["bedtools"]="arq5x/bedtools2" ["bcftools"]="samtools/bcftools" ["bwa"]="lh3/bwa" ["picard"]="broadinstitute/picard" \
["star"]="alexdobin/STAR" ["umitools"]="CGATOxford/UMI-tools" ["rtorch"]="mlverse/torch")

for DOCKER in "${!github_dict[@]}"
do
LATEST_VERSION=$(curl --silent "https://api.github.com/repos/${github_dict[$DOCKER]}/releases/latest" | jq -r .tag_name)
CURRENT_VERSION=$(get_current_version "$DOCKER")
echo "${DOCKER}:${CURRENT_VERSION}:${LATEST_VERSION}" >> version_list.txt
done

## Tools with PyPi API calls
declare -A pypi_dict=(["scanpy"]="scanpy" ["scvi-tools"]="scvi-tools")
for DOCKER in "${!pypi_dict[@]}"
do
LATEST_VERSION=$(curl --silent "https://pypi.org/pypi/${pypi_dict[$DOCKER]}/json" | jq -r '.info.version')
CURRENT_VERSION=$(get_current_version "$DOCKER")
echo "${DOCKER}:${CURRENT_VERSION}:${LATEST_VERSION}" >> version_list.txt
done

## GATK
LATEST_VERSION=$(curl --silent "https://api.anaconda.org/package/bioconda/gatk4" | jq -r '.latest_version')
CURRENT_VERSION=$(get_current_version "gatk")
echo "gatk:${CURRENT_VERSION}:${LATEST_VERSION}" >> version_list.txt

# ## sra-tools
# TOOL="sra-tools"
# LATEST_VERSION=$(curl --silent "https://api.github.com/repos/ncbi/${TOOL}/tags" | jq -r '.[0].name')
# CURRENT_VERSION=$(get_current_version "$TOOL")
# echo "${TOOL}:${CURRENT_VERSION}:${LATEST_VERSION}" >> version_list.txt

{ echo Tool:Current_version: Latest_version; cat version_list.txt; } | csvlook > version_table.txt

rm version_list.txt
37 changes: 37 additions & 0 deletions .github/workflows/docker-version-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Dockerfile Version Check


on:
workflow_dispatch:
push:
branches:
- main
- automate_version_check
schedule:
- cron: "0 0 1 * *" # Run every 1 month

env:
GH_TOKEN: ${{ github.token }}


jobs:
check-version:
runs-on: ubuntu-latest
permissions:
issues: write
defaults:
run:
working-directory: ./.github
steps:
- name: Check out the repository to the runner
uses: actions/checkout@v4
- name: Install jq, curl, csvkit
run: |
sudo apt-get update
sudo apt-get install -y jq curl csvkit
- name: Make the script files executable
run: chmod +x version_check.sh
- name: Run the scripts
run: |
./version_check.sh
gh issue create --repo getwilds/wilds-docker-library --title "$(date +%B): Docker version check" --body-file version_table.txt