Updating Freyja #281
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ##### ------------------------------------------------------------------------------------------------ ##### | |
| ##### This caller workflow tests, builds, and pushes the image to Docker Hub and Quay using the most ##### | |
| ##### recent version of Freyja and downloading the most recent variant information. ##### | |
| ##### It takes no manual input. ##### | |
| ##### ------------------------------------------------------------------------------------------------ ##### | |
| name: Update Freyja | |
| on: | |
| workflow_dispatch: | |
| schedule: | |
| - cron: '30 7 * * 1' | |
| run-name: Updating Freyja | |
| jobs: | |
| update: | |
| if: github.repository == 'StaPH-B/docker-builds' | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| FREYJA_PATHOGEN: | |
| - SARS-CoV-2 | |
| - MPX | |
| - H5Nx | |
| - H5Nx-cattle | |
| - H1N1 | |
| - FLU-B-VIC | |
| - H3N2 | |
| - MEASLESgenome | |
| - RSVa | |
| - RSVb | |
| - DENV1 | |
| - DENV2 | |
| - DENV3 | |
| - DENV4 | |
| - MTB | |
| steps: | |
| - name: pull repo | |
| uses: actions/checkout@v4 | |
| - name: set freyja version | |
| id: latest_version | |
| run: | | |
| version=2.0.3 | |
| echo "version=$version" >> $GITHUB_OUTPUT | |
| file=build-files/freyja/$version/Dockerfile | |
| ls $file | |
| echo "file=$file" >> $GITHUB_OUTPUT | |
| - name: set up docker buildx | |
| id: buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: build to test | |
| id: docker_build_to_test | |
| uses: docker/build-push-action@v5 | |
| with: | |
| file: ${{ steps.latest_version.outputs.file }} | |
| target: test | |
| load: true | |
| push: false | |
| tags: freyja:update-${{ matrix.FREYJA_PATHOGEN }} | |
| build-args: | | |
| FREYJA_PATHOGEN=${{ matrix.FREYJA_PATHOGEN }} | |
| - name: get freyja database version | |
| id: db_version | |
| run: | | |
| docker run freyja:update-${{ matrix.FREYJA_PATHOGEN }} \ | |
| freyja demix --version --pathogen ${{ matrix.FREYJA_PATHOGEN }} | |
| version=$(docker run freyja:update-${{ matrix.FREYJA_PATHOGEN }} \ | |
| freyja demix --version --pathogen ${{ matrix.FREYJA_PATHOGEN }} \ | |
| | tail -n 3 | head -n 1) | |
| echo "the latest version is $version" | |
| echo "version=$version" >> $GITHUB_OUTPUT | |
| - name: Get current date | |
| id: date | |
| run: | | |
| date=$(date '+%Y-%m-%d') | |
| echo "the date is $date" | |
| echo "date=$date" >> $GITHUB_OUTPUT | |
| - name: Set image tags | |
| id: tags | |
| run: | | |
| TAGS="staphb/freyja:${{ steps.latest_version.outputs.version }}-${{ matrix.FREYJA_PATHOGEN }}-${{ steps.db_version.outputs.version }}-${{ steps.date.outputs.date }} | |
| quay.io/staphb/freyja:${{ steps.latest_version.outputs.version }}-${{ matrix.FREYJA_PATHOGEN }}-${{ steps.db_version.outputs.version }}-${{ steps.date.outputs.date }}" | |
| if [ "${{ matrix.FREYJA_PATHOGEN }}" = "SARS-CoV-2" ]; then | |
| TAGS="$TAGS | |
| staphb/freyja:latest | |
| quay.io/staphb/freyja:latest" | |
| fi | |
| echo "tags<<EOF" >> $GITHUB_OUTPUT | |
| echo "$TAGS" >> $GITHUB_OUTPUT | |
| echo "EOF" >> $GITHUB_OUTPUT | |
| - name: Login to DockerHub | |
| uses: docker/login-action@v3 | |
| with: | |
| username: ${{ secrets.DOCKER_HUB_USERNAME }} | |
| password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} | |
| - name: Login to Quay | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: quay.io | |
| username: ${{ secrets.QUAY_USERNAME }} | |
| password: ${{ secrets.QUAY_ROBOT_TOKEN }} | |
| - name: Build and push Dockerfile | |
| id: docker_build_and_push | |
| uses: docker/build-push-action@v5 | |
| with: | |
| file: ${{ steps.latest_version.outputs.file }} | |
| target: app | |
| push: true | |
| build-args: | | |
| FREYJA_PATHOGEN=${{ matrix.FREYJA_PATHOGEN }} | |
| tags: ${{ steps.tags.outputs.tags }} | |
| - name: Image digest | |
| run: echo ${{ steps.docker_build_and_push.outputs.digest }} |