-
Notifications
You must be signed in to change notification settings - Fork 1
58 lines (49 loc) · 1.73 KB
/
build-docker-images.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
name: Build and Push Docker Images
on:
push:
branches: [develop, 'GEN*', 'gen*']
paths:
- 'scripts/references/**'
- '.github/workflows/build-docker-images.yml'
jobs:
build_references_docker:
runs-on: ubuntu-latest
env:
REGISTRY: ghcr.io
IMAGE_NAME: sagebionetworks/genie-bpc-pipeline-references
TAG: ${{ github.ref_name }}
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 2
- name: Fetch the default branch (develop) for comparison
run: git fetch origin develop:refs/remotes/origin/develop --depth=1
- name: Check for Changes in scripts/references
id: check_changes
run: |
# Check for a merge base, fallback to root commit if none exists
if git merge-base --is-ancestor origin/develop HEAD; then
DIFF_BASE="origin/develop"
else
DIFF_BASE=$(git rev-list --max-parents=0 HEAD) # Use the initial commit as fallback
fi
# Compare changes between DIFF_BASE and HEAD
if git diff --name-only $DIFF_BASE -- scripts/references | grep -q .; then
echo "CHANGED=true" >> $GITHUB_ENV
else
echo "CHANGED=false" >> $GITHUB_ENV
fi
- name: Log in to GitHub Container Registry
if: env.CHANGED == 'true'
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and Push Docker Image for scripts/references
if: env.CHANGED == 'true'
uses: docker/build-push-action@v5
with:
context: scripts/references
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.ref_name }}