-
Notifications
You must be signed in to change notification settings - Fork 119
44 lines (44 loc) · 1.25 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
name: docker
on:
push:
branches:
- main
pull_request:
branches:
- main
paths:
- Dockerfile
- .github/workflows/docker.yml
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: docker/setup-buildx-action@v2
- if: github.ref == 'refs/heads/main'
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_TOKEN }}
- name: determine tags
id: tags
run: |
DOCKER_IMAGE=lyft/clutch
VERSION=latest
TAGS="${DOCKER_IMAGE}:${VERSION}"
TAGS="$TAGS,${DOCKER_IMAGE}:sha-${GITHUB_SHA::7}"
echo "tags=${TAGS}" >>${GITHUB_OUTPUT}
- name: build and push
if: github.ref == 'refs/heads/main'
uses: docker/[email protected]
with:
tags: ${{ steps.tags.outputs.tags }}
push: true
cache-from: type=registry,ref=lyft/clutch:latest
- name: build
if: github.ref != 'refs/heads/main'
uses: docker/[email protected]
with:
tags: ${{ steps.tags.outputs.tags }}
push: false
cache-from: type=registry,ref=lyft/clutch:latest