-
Notifications
You must be signed in to change notification settings - Fork 237
94 lines (89 loc) · 3.12 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# Builds and uploads docker images whenever a version tag is pushed. When a release is created,
# the associated image is then tagged with the version number and latest.
name: Docker
on:
workflow_dispatch:
push:
tags:
- 'v*'
release:
types: [published]
env:
# Workaround for https://github.com/rust-lang/cargo/issues/8719#issuecomment-1516492970
CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse
jobs:
# Build a docker image unless this was triggered by a release.
build-image:
if: github.event_name != 'release'
runs-on: pathfinder-large-ubuntu
steps:
- name: Determine Docker image metadata
id: meta
uses: docker/metadata-action@v4
with:
images: eqlabs/pathfinder
- name: Checkout sources
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Generate version
id: generate_version
run: |
echo -n "pathfinder_version=" >> $GITHUB_OUTPUT
git describe --tags --dirty >> $GITHUB_OUTPUT
- name: Set up QEMU
id: qemu
uses: docker/setup-qemu-action@v2
with:
image: tonistiigi/binfmt:latest
platforms: all
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v2
with:
config-inline: |
[worker.oci]
max-parallelism = 4
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
# Required for git security reasons. See https://github.com/rustyhorde/vergen/pull/126#issuecomment-1201088162
- name: Vergen git safe directory
run: git config --global --add safe.directory /workspace
- name: Build
id: docker_build
uses: docker/build-push-action@v3
with:
context: .
platforms: |
linux/amd64
linux/arm64
file: ./Dockerfile
build-args: |
PATHFINDER_FORCE_VERSION=${{ steps.generate_version.outputs.pathfinder_version }}
builder: ${{ steps.buildx.outputs.name }}
push: true
labels: ${{ steps.meta.outputs.labels }}
tags: eqlabs/pathfinder:snapshot-${{ github.sha }}
cache-from: type=gha
cache-to: type=gha,mode=max
# Add the release labels to the associated docker image.
tag-release:
if: github.event_name == 'release'
runs-on: ubuntu-latest
steps:
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
- name: Pull image
run: docker pull eqlabs/pathfinder:snapshot-${{ github.sha }}
- name: Tag image
run: |
docker tag eqlabs/pathfinder:snapshot-${{ github.sha }} eqlabs/pathfinder:latest
docker tag eqlabs/pathfinder:snapshot-${{ github.sha }} eqlabs/pathfinder:${{ github.event.release.tag_name }}
- name: Push image tags
run: docker push --all-tags eqlabs/pathfinder