1+ name : Build
2+
3+ # Controls when the workflow will run
4+ on :
5+ workflow_dispatch :
6+ push :
7+ branches :
8+ - ' main'
9+ tags :
10+ - ' v*.*.*'
11+ pull_request :
12+ branches :
13+ - ' main'
14+
15+ # GH
16+ permissions :
17+ contents : read
18+
19+ jobs :
20+ build :
21+ runs-on : ubuntu-latest
22+ steps :
23+ # Get the repository's code
24+ - name : Checkout
25+ uses : actions/checkout@v3
26+ # https://github.com/docker/setup-qemu-action
27+ - name : Set up QEMU
28+ uses : docker/setup-qemu-action@v2
29+ # https://github.com/docker/setup-buildx-action
30+ - name : Set up Docker Buildx
31+ id : buildx
32+ uses : docker/setup-buildx-action@v2
33+ - name : Login to Docker Hub
34+ if : github.event_name != 'pull_request'
35+ uses : docker/login-action@v2
36+ with :
37+ username : ${{ secrets.DOCKERHUB_USERNAME }}
38+ password : ${{ secrets.DOCKERHUB_TOKEN }}
39+
40+ - name : Docker meta
41+ id : ourdockertags
42+ uses : docker/metadata-action@v3
43+ with :
44+ # list of Docker images to use as base name for tags
45+ images : |
46+ docker.io/tinpotnick/violet
47+ # Docker tags based on the following events/attributes
48+ tags : |
49+ type=schedule
50+ type=ref,event=branch
51+ type=ref,event=pr
52+ type=semver,pattern={{version}}
53+ type=semver,pattern={{major}}.{{minor}}
54+ type=semver,pattern={{major}}
55+ type=sha
56+
57+ - name : Build and push
58+ uses : docker/build-push-action@v4
59+ with :
60+ context : .
61+ platforms : linux/amd64,linux/arm64
62+ push : ${{ github.event_name != 'pull_request' }}
63+ tags : ${{ steps.ourdockertags.outputs.tags }}
64+ labels : ${{ steps.ourdockertags.outputs.labels }}
0 commit comments