-
Notifications
You must be signed in to change notification settings - Fork 3
59 lines (53 loc) · 2.09 KB
/
docker.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
48
49
50
51
52
53
54
55
56
57
58
name: docker
on:
push:
branches:
- main
env:
IMAGE_NAME: ghcr.io/${{ github.repository }}
jobs:
# Extract the VERSION which is either `latest` or `vX.Y.Z`, and the VERSION_SUFFIX
# which is either empty or `-unstable`.
#
# It would be nice if the arch didn't get spliced into the version between `latest` and
# `unstable`, but for now we keep the two parts of the version separate for backwards
# compatibility.
extract-version:
runs-on: ubuntu-22.04
steps:
- name: Extract version (if main)
if: github.event.ref == 'refs/heads/main'
run: |
echo "VERSION=latest" >> $GITHUB_ENV
echo "VERSION_SUFFIX=" >> $GITHUB_ENV
outputs:
VERSION: ${{ env.VERSION }}
VERSION_SUFFIX: ${{ env.VERSION_SUFFIX }}
build-docker-single-arch:
name: build-docker-x86_64
runs-on: ubuntu-22.04
permissions:
contents: read
packages: write
needs: [extract-version]
env:
# We need to enable experimental docker features in order to use `docker buildx`
DOCKER_CLI_EXPERIMENTAL: enabled
VERSION: ${{ needs.extract-version.outputs.VERSION }}
VERSION_SUFFIX: ${{ needs.extract-version.outputs.VERSION_SUFFIX }}
steps:
- uses: actions/checkout@v3
- uses: docker/setup-qemu-action@v2
- name: Dockerhub login
run: |
echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io --username "${{ github.repository_owner }}" --password-stdin
- name: Map x86_64 to amd64 short arch
run: echo "SHORT_ARCH=amd64" >> $GITHUB_ENV;
- name: Build Dockerfile and push
run: |
docker buildx build \
--platform=linux/${SHORT_ARCH} \
--file ./Dockerfile . \
--tag ${IMAGE_NAME}:${VERSION}${VERSION_SUFFIX} \
--provenance=false \
--push