-
Notifications
You must be signed in to change notification settings - Fork 31
47 lines (40 loc) · 1.24 KB
/
build-container.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
46
47
name: container-images
on:
push:
branches: [ "main" ]
tags: [ "v*" ]
jobs:
build-and-push:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: docker/setup-qemu-action@v1
- uses: docker/setup-buildx-action@v1
- run: echo "IMAGE_TAG=dev" >> $GITHUB_ENV
if: github.ref_name == 'main'
- run: echo "IMAGE_TAG=${GITHUB_REF##*/}" >> $GITHUB_ENV
if: startsWith(github.ref, 'refs/tags/v')
- name: Login to ghcr.io
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Login to docker.io
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_HUB_UID }}
password: ${{ secrets.DOCKER_HUB_PAT }}
- name: Build image
run: |
docker buildx build \
--platform linux/amd64,linux/arm64,linux/arm/v7,linux/arm/v6 \
--tag ghcr.io/${{ github.repository }}:${{ env.IMAGE_TAG }} \
--tag ${{ secrets.DOCKER_HUB_REPO }}:${{ env.IMAGE_TAG }} \
--file ./Dockerfile \
--output type=image,push=true .