-
Notifications
You must be signed in to change notification settings - Fork 17
45 lines (39 loc) · 1.37 KB
/
ci.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
name: Build Docker image
on:
push:
pull_request:
jobs:
ci:
name: Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to Docker Hub
if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/next'
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Extract tags
shell: bash
run: |
branch_name=${GITHUB_REF#refs/heads/}
tags=henrist/zerotier-one
if [ "$branch_name" = "master" ]; then
major_minor=$(grep ZEROTIER_VERSION= Dockerfile | sed -r 's/.+=([0-9]+\.[0-9]+)\..+/\1/')
tags=henrist/zerotier-one:latest,henrist/zerotier-one:$major_minor
elif [ "$branch_name" = "next" ]; then
tags=henrist/zerotier-one:next
fi
echo "##[set-output name=tags;]$(echo "$tags")"
id: extract_tags
- name: Build Docker image
uses: docker/build-push-action@v5
with:
context: .
push: ${{ github.ref == 'refs/heads/master' || github.ref == 'refs/heads/next' }}
tags: ${{ steps.extract_tags.outputs.tags }}
cache-from: type=gha
cache-to: type=gha,mode=max