-
Notifications
You must be signed in to change notification settings - Fork 203
100 lines (90 loc) · 3.42 KB
/
Copy pathdocker.yml
File metadata and controls
100 lines (90 loc) · 3.42 KB
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
95
96
97
98
99
100
# Dojo docker image build and push workflow.
#
# This workflow is triggered by a workflow_dispatch event or when a new release with a tag starting with `v` is published.
#
# The docker image is built by using `asdf` to bundle the Dojo binaries with the docker image, there is no heavy compilation
# of the Dojo binaries during this workflow.
#
# The docker image is pushed to the GitHub Container Registry: https://github.com/dojoengine/dojo/pkgs/container/dojo
#
name: docker build and push
on:
workflow_dispatch:
inputs:
tag_name:
description: "The docker image tag name"
required: true
type: string
dojo_version:
description: "The dojo version to install in the docker image"
required: true
type: string
release:
types: [published]
env:
CARGO_TERM_COLOR: always
RUST_VERSION: 1.88.0
REGISTRY_IMAGE: ghcr.io/${{ github.repository }}
jobs:
prepare:
# Only run for full Dojo releases (tags starting with `v`). Sozo-only releases
# use the `sozo/v*` tag format and are published by `release-sozo.yml`, which
# has its own dedicated docker-image job.
if: github.event_name == 'workflow_dispatch' || (github.event_name == 'release' && startsWith(github.event.release.tag_name, 'v'))
runs-on: ubuntu-latest-4-cores
outputs:
tag_name: ${{ steps.version_info.outputs.tag_name }}
dojo_version: ${{ steps.version_info.outputs.dojo_version }}
steps:
- uses: actions/checkout@v3
- name: Extract version info
id: version_info
run: |
if [[ "${{ github.ref }}" == refs/tags/* ]]; then
# Extract tag name from ref
echo "tag_name=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
echo "dojo_version=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
else
# We're supposed to be in a workflow_dispatch here.
# A `if` is not used at the job level since the id of a step must be unique across the job.
if [ -z "${{ inputs.tag_name }}" ]; then
echo "tag_name is empty"
exit 1
fi
# The tag name must start with v to ensure consistency with tags.
TAG_NAME="${{ inputs.tag_name }}"
if [[ ! "$TAG_NAME" =~ ^v ]]; then
TAG_NAME="v$TAG_NAME"
fi
echo "tag_name=$TAG_NAME" >> $GITHUB_OUTPUT
echo "dojo_version=${{ inputs.dojo_version }}" >> $GITHUB_OUTPUT
fi
docker-build-and-push:
runs-on: ubuntu-latest
needs: prepare
strategy:
matrix:
job:
- os: ubuntu-latest
platform: linux/amd64
- os: ubuntu-24.04-arm
platform: linux/arm64
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push docker image
uses: docker/build-push-action@v3
with:
push: true
tags: ghcr.io/${{ github.repository }}:latest,ghcr.io/${{ github.repository }}:${{ needs.prepare.outputs.tag_name }}
platforms: ${{ matrix.platform }}
build-args: |
DOJO_VERSION=${{ needs.prepare.outputs.dojo_version }}