-
Notifications
You must be signed in to change notification settings - Fork 3
84 lines (76 loc) · 2.36 KB
/
docker_image_workflow.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
name: Publish Docker image
on:
push:
tags:
- "v[0-9]+.[0-9]+.[0-9]+"
- "dev[0-9]-v[0-9]+.[0-9]+.[0-9]+"
paths:
- "docker/**"
- "env/**"
- "app/**"
- "run/**"
- ".github/**"
jobs:
build_test_push:
runs-on: ubuntu-latest
steps:
- name: Free Disk Space (Ubuntu)
uses: jlumbroso/free-disk-space@main
with:
tool-cache: false
large-packages: true
docker-images: false
swap-storage: true
- name: Checkout
uses: actions/checkout@v4
- name: Prepare
id: prep
run: |
DOCKER_IMAGE=registry.gitlab.com/ncsa-blast/kubernetes/blast
if [[ $GITHUB_REF == refs/tags/v* ]]; then
VERSION=${GITHUB_REF#refs/tags/}
TAGS="${DOCKER_IMAGE}:${VERSION},${DOCKER_IMAGE}:latest"
elif [[ $GITHUB_REF == refs/tags/dev* ]]; then
VERSION=${GITHUB_REF#refs/tags/}
TAGS="${DOCKER_IMAGE}:${VERSION},${DOCKER_IMAGE}:dev"
fi
echo ::set-output name=tags::${TAGS}
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v3
- name: Login to container registry
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
registry: "registry.gitlab.com"
username: "${{ secrets.GITLAB_REGISTRY_USERNAME }}"
password: "${{ secrets.GITLAB_REGISTRY_TOKEN }}"
- name: Build and export to Docker
id: docker_build
uses: docker/build-push-action@v6
with:
builder: ${{ steps.buildx.outputs.name }}
context: ./app
file: ./app/Dockerfile
tags: ${{ steps.prep.outputs.tags }}
cache-from: type=gha
cache-to: type=gha,mode=max
push: false
load: true
- name: Run tests
run: bash run/blastctl ci up
# - uses: codecov/codecov-action@v4
# with:
# directory: app/
- name: Push image
id: docker_push
uses: docker/build-push-action@v6
with:
builder: ${{ steps.buildx.outputs.name }}
context: ./app
file: ./app/Dockerfile
tags: ${{ steps.prep.outputs.tags }}
cache-from: type=gha
cache-to: type=gha,mode=max
platforms: linux/amd64
push: true