-
-
Notifications
You must be signed in to change notification settings - Fork 186
103 lines (92 loc) · 3.33 KB
/
Copy pathdocker-build.yml
File metadata and controls
103 lines (92 loc) · 3.33 KB
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
98
99
100
101
102
103
name: Docker Build and Push
on:
push:
branches:
- master
tags:
- 'v*.*.*'
pull_request:
branches:
- master
paths:
- 'Dockerfile'
- 'conda-env.yml'
- '.github/workflows/docker-build.yml'
env:
DOCKER_IMAGE: etal/cnvkit
# Alternative: ghcr.io/${{ github.repository_owner }}/cnvkit
jobs:
build-and-push:
name: Build and Push Docker Image
runs-on: ubuntu-latest
permissions:
contents: read
packages: write # For GitHub Container Registry
steps:
- name: Checkout repository
uses: actions/checkout@v6
with:
fetch-depth: 0 # Full history for version info
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4
- name: Log in to Docker Hub
if: github.event_name != 'pull_request'
uses: docker/login-action@v4
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
# Uncomment to enable GitHub Container Registry as backup
# - name: Log in to GitHub Container Registry
# if: github.event_name != 'pull_request'
# uses: docker/login-action@v4
# with:
# registry: ghcr.io
# username: ${{ github.actor }}
# password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract version from tag
id: version
run: |
if [[ $GITHUB_REF == refs/tags/v* ]]; then
VERSION=${GITHUB_REF#refs/tags/v}
echo "version=${VERSION}" >> $GITHUB_OUTPUT
echo "is_release=true" >> $GITHUB_OUTPUT
else
echo "version=devel" >> $GITHUB_OUTPUT
echo "is_release=false" >> $GITHUB_OUTPUT
fi
- name: Docker metadata
id: meta
uses: docker/metadata-action@v6
with:
images: ${{ env.DOCKER_IMAGE }}
tags: |
# Tag with version on release tags (e.g., v0.9.13 -> 0.9.13)
type=semver,pattern={{version}}
# Tag with major.minor on release tags (e.g., v0.9.13 -> 0.9)
type=semver,pattern={{major}}.{{minor}}
# Tag as 'latest' on release tags
type=raw,value=latest,enable=${{ startsWith(github.ref, 'refs/tags/v') }}
# Tag as 'devel' on master branch commits
type=raw,value=devel,enable=${{ github.ref == 'refs/heads/master' }}
labels: |
org.opencontainers.image.title=CNVkit
org.opencontainers.image.description=Copy number variant detection from high-throughput sequencing
org.opencontainers.image.vendor=Eric Talevich
- name: Build and push Docker image
uses: docker/build-push-action@v7
with:
context: .
file: ./Dockerfile
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
platforms: linux/amd64,linux/arm64
cache-from: type=gha
cache-to: type=gha,mode=max
build-args: |
CNVKIT_VERSION=${{ steps.version.outputs.is_release == 'true' && steps.version.outputs.version || '' }}
- name: Docker image digest
if: github.event_name != 'pull_request'
run: |
echo "Image pushed with tags:"
echo "${{ steps.meta.outputs.tags }}"