-
Notifications
You must be signed in to change notification settings - Fork 6
63 lines (41 loc) · 1.41 KB
/
docker.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
name: Build and Push to GCR
on: [push]
env:
IMAGE: us.gcr.io/broad-gotc-prod/pipeline-tools
jobs:
build-push:
name: Build and Push
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
# Setup gcloud CLI
- uses: google-github-actions/setup-gcloud@master
with:
version: '270.0.0'
service_account_key: ${{ secrets.GCLOUD_SERVICE_KEY }}
# Configure docker to use gcloud command-line
- run: |
gcloud auth configure-docker
# Build image for each branch push
- name: Build/Push all
run: |
export BRANCH=${GITHUB_REF#refs/heads/}
echo "Building ${IMAGE}:${BRANCH}"
docker build -t "${IMAGE}:${BRANCH}" .
echo "Pushing ${IMAGE}:${BRANCH}"
docker push "${IMAGE}:${BRANCH}"
# Build image for merge to master
- name: Build/Push master
if: contains ('refs/heads/master', github.ref)
run: |
export TIMESTAMP=$(date +"%s")
echo "Building ${IMAGE}:latest"
docker build -t "${IMAGE}:latest" .
docker tag "${IMAGE}:latest" "${IMAGE}:master_${TIMESTAMP}"
echo "Pushing ${IMAGE}:latest"
echo "Pushing ${IMAGE}:master_${TIMESTAMP}"
docker push "${IMAGE}:latest"
docker push "${IMAGE}:master_${TIMESTAMP}"
- run: |
echo "Successfully completed"