1+ name: branch build & push
2+
3+ on:
4+ #schedule:
5+ # - cron: '50 15 * * *' #Change this to when you want automatic builds
6+ push:
7+ paths-ignore:
8+ - 'README.md'
9+ tags: [ 'v*.*.*' ]
10+ workflow_dispatch:
11+
12+ env:
13+ REGISTRY: docker.io
14+ IMAGE_NAME: ${{ secrets.DOCKERHUB_IMAGE_NAME }}
15+
16+ jobs:
17+ build:
18+
19+ runs-on: ubuntu-latest
20+ permissions:
21+ contents: read
22+ packages: write
23+ # This is used to complete the identity challenge
24+ # with sigstore/fulcio when running outside of PRs.
25+ id-token: write
26+
27+ steps:
28+ - name: Checkout repository
29+ uses: actions/checkout@v2
30+
31+ - name: Set up QEMU
32+ uses: docker/setup-qemu-action@v1
33+
34+ - name: Setup Docker buildx
35+ uses: docker/setup-buildx-action@1
36+
37+ - name: Cache Docker layers
38+ uses: actions/cache@v2
39+ with:
40+ path: /tmp/.buildx-cache
41+ key: ${{ runner.os }}-buildx-${{ github.sha }}
42+ restore-keys: |
43+ ${{ runner.os }}-buildx-
44+
45+ - name: Login to Docker Hub
46+ uses: docker/login-action@v1
47+ with:
48+ username: ${{ secrets.DOCKERHUB_USERNAME }}
49+ password: ${{ secrets.DOCKERHUB_TOKEN }}
50+
51+ - name: Build and push
52+ uses: docker/build-push-action@v2
53+ with:
54+ context: .
55+ push: true
56+ tags: ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.DOCKERHUB_IMAGE_NAME }}:${{steps.vars.outputs.tag}}
57+ platforms: linux/amd64,linux/arm/v7,linux/arm64/v8
58+ cache-from: type=local,src=/tmp/.buildx-cache
59+ cache-to: type=local,dest=/tmp/.buildx-cache-new
60+
61+ - name: Build and push
62+ uses: docker/build-push-action@v2
63+ with:
64+ context: .
65+ push: true
66+ tags: ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.DOCKERHUB_IMAGE_NAME }}:latest
67+ platforms: linux/amd64,linux/arm/v7,linux/arm64/v8
68+ cache-from: type=local,src=/tmp/.buildx-cache
69+ cache-to: type=local,dest=/tmp/.buildx-cache-new
70+
71+ - name: Move cache
72+ run: |
73+ rm -rf /tmp/.buildx-cache
74+ mv /tmp/.buildx-cache-new /tmp/.buildx-cache
0 commit comments