-
Notifications
You must be signed in to change notification settings - Fork 1
97 lines (81 loc) · 2.58 KB
/
publish.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
name: Docker publish
on:
workflow_dispatch:
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: Create tag version
id: tag
run: |
conda activate livedata
echo "tag=$(versioningit)" >> $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: deploy/django/Dockerfile
tags: ${{ env.REGISTRY }}/${{ github.repository }}/live_data_server:${{ steps.latest_tag.outputs.latest_tag }}
push: true
- name: Push version tag for branches qa and main
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/qa'
uses: docker/build-push-action@v6
with:
context: .
file: deploy/django/Dockerfile
tags: ${{ env.REGISTRY }}/${{ github.repository }}/live_data_server:${{ steps.tag.outputs.tag }}
push: true