forked from dani-garcia/vaultwarden
-
Notifications
You must be signed in to change notification settings - Fork 0
65 lines (55 loc) · 1.72 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
56
57
58
59
60
61
62
63
64
65
name: Build Docker Image
on:
push:
branches: [main, test]
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
build-and-push:
runs-on: ubuntu-latest
strategy:
matrix:
base_image: [alpine, debian]
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
with:
platforms: arm64
- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Determine Base Tags
shell: bash
run: |
if [[ "${{ github.ref_name }}" == "main" ]]; then
echo "BASE_TAGS=latest" | tee -a "${GITHUB_ENV}"
else
echo "BASE_TAGS=${{ github.ref_name }}" | tee -a "${GITHUB_ENV}"
fi
- name: Bake ${{ matrix.base_image }} containers
uses: docker/bake-action@v4
env:
BASE_TAGS: "${{ env.BASE_TAGS }}"
CONTAINER_REGISTRIES: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
SOURCE_REPOSITORY_URL: "${{ github.server_url }}/${{ github.repository }}"
SOURCE_VERSION: ${{ github.sha }}
VW_VERSION: ${{ github.sha }}
with:
push: true
files: docker/docker-bake.hcl
targets: ${{ matrix.base_image }}-multi
set: |
*.platform=linux/amd64,linux/arm64
*.cache-from=type=gha
*.cache-to=type=gha,mode=max