diff --git a/.github/version_check.sh b/.github/version_check.sh new file mode 100644 index 0000000..d870d47 --- /dev/null +++ b/.github/version_check.sh @@ -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 \ No newline at end of file diff --git a/.github/workflows/docker-version-check.yml b/.github/workflows/docker-version-check.yml new file mode 100644 index 0000000..c3f8e5e --- /dev/null +++ b/.github/workflows/docker-version-check.yml @@ -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