-
Notifications
You must be signed in to change notification settings - Fork 10
55 lines (47 loc) · 1.51 KB
/
build_and_push.yaml
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
name: Docker Build
on:
push:
branches:
- main
jobs:
build-and-push:
name: Build and push
runs-on: ubuntu-latest
steps:
# Create a commit SHA-based tag for the container repositories
- name: Create Container Tags
id: tags_generator
run: |
tag=$(cut -c 1-7 <<< $GITHUB_SHA)
echo "::set-output name=tag::$tag"
# Check out the current repository
- name: Checkout repository
uses: actions/checkout@v3
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
with:
platforms: arm64
# Set up Docker Buildx and log into DockerHub
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
with:
platforms: linux/amd64,linux/arm64
- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
# Build and push the container to the GitHub Container
# Repository. The container will be tagged as "latest"
# and with the short SHA of the commit.
- name: Build and push
uses: docker/build-push-action@v3
with:
context: .
file: ./docker/Dockerfile
push: true
cache-from: type=registry,ref=lemonsaurus/blackbox:main
cache-to: type=inline
tags: |
lemonsaurus/blackbox:main
lemonsaurus/blackbox:${{ steps.tags_generator.outputs.tag }}