Skip to content

Commit

Permalink
Add docker publish action
Browse files Browse the repository at this point in the history
  • Loading branch information
rosswhitfield committed Jun 20, 2024
1 parent 885e6d6 commit edbeba5
Show file tree
Hide file tree
Showing 2 changed files with 96 additions and 2 deletions.
94 changes: 94 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
name: Docker publish

on:
push:
branches:
- next
- qa
- main

env:
# Use docker.io for Docker Hub if empty
REGISTRY: ghcr.io

jobs:
build:

runs-on: ubuntu-latest
defaults:
run:
shell: bash -l {0}

steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: conda-incubator/setup-miniconda@v3
with:
auto-update-conda: true
channels: conda-forge,defaults
mamba-version: "*"
environment-file: environment.yml
cache-environment-key: ${{ runner.os }}-env-${{ hashFiles('**/environment.yml') }}
cache-downloads-key: ${{ runner.os }}-downloads-${{ hashFiles('**/environment.yml') }}
- name: Install requirements
run: |
# --quiet should turn off progress bars to make logs more readable
conda env create
- name: Get version
id: version
run: |
conda activate livedata
echo "version=$(versioningit)" >> $GITHUB_OUTPUT
- name: Create tag version
id: tag
run: |
conda activate livedata
echo "tag=$(versioningit).b$(date +'%Y%m%d%H%M')" >> $GITHUB_OUTPUT
- name: Create latest tag version
id: latest_tag
run: |
case ${{ github.ref }} in
refs/heads/next)
echo "latest_tag=latest-dev" >> $GITHUB_OUTPUT
;;
refs/heads/qa)
echo "latest_tag=latest-test" >> $GITHUB_OUTPUT
;;
refs/heads/main)
echo "latest_tag=latest-prod" >> $GITHUB_OUTPUT
;;
*)
exit 1
;;
esac
- name: Check tag names
run: |
echo ${{ steps.latest_tag.outputs.latest_tag }}
echo ${{ steps.tag.outputs.tag }}
- name: Log into registry ${{ env.REGISTRY }}
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push docker image
uses: docker/build-push-action@v6
with:
context: .
file: Dockerfile
tags: |
${{ env.REGISTRY }}/${{ github.repository }}/live_data_server:${{ steps.latest_tag.outputs.latest_tag }}
${{ env.REGISTRY }}/${{ github.repository }}/live_data_server:${{ steps.tag.outputs.tag }}
push: true
4 changes: 2 additions & 2 deletions .github/workflows/unittest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ jobs:
DJANGO_SUPERUSER_USERNAME: livedatauser
DJANGO_SUPERUSER_PASSWORD: livedatapass
steps:
- uses: actions/checkout@v3
- uses: conda-incubator/setup-miniconda@v2
- uses: actions/checkout@v4
- uses: conda-incubator/setup-miniconda@v3
with:
auto-update-conda: true
channels: conda-forge,defaults
Expand Down

0 comments on commit edbeba5

Please sign in to comment.