-
Notifications
You must be signed in to change notification settings - Fork 16
57 lines (56 loc) · 1.88 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
name: docker
on:
push:
branches:
- main
tags:
- v*
pull_request:
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Get latest tag
run: |
git fetch --tags
echo "current_tag=$(echo ${GITHUB_REF#refs/tags/})" >> $GITHUB_ENV
echo "latest_tag=$(git describe --tags `git rev-list --tags --max-count=1`)" >> $GITHUB_ENV
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Build only
id: docker_build_only
uses: docker/build-push-action@v2
with:
platforms: linux/amd64,linux/arm64
push: false
tags: madflojo/tarmac:${{ github.sha }}
- name: Login to DockerHub
id: docker_login
if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v')
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push (main)
id: docker_build
if: github.ref == 'refs/heads/main'
uses: docker/build-push-action@v2
with:
platforms: linux/amd64,linux/arm64
push: ${{ github.event_name == 'push' && 'true' || 'false' }}
tags: madflojo/tarmac:unstable
- name: Build and push (tag)
id: docker_build_tag
if: startsWith(github.ref, 'refs/tags/v')
uses: docker/build-push-action@v2
with:
platforms: linux/amd64,linux/arm64
push: ${{ github.event_name == 'push' && 'true' || 'false' }}
# tag with the git tag v*
tags: |
madflojo/tarmac:${{ github.ref_name }}
${{ env.latest_tag == env.current_tag && 'madflojo/tarmac:latest' }}