-
Notifications
You must be signed in to change notification settings - Fork 1
74 lines (65 loc) · 2.1 KB
/
build-an-image.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
name: Build An Image (Do not use directly)
on:
workflow_call:
inputs:
IMAGE_NAME:
required: true
type: string
BUILD_DIR:
required: true
type: string
TEST_TAG:
required: true
type: string
PUSH_TAG:
required: true
type: string
EXTRA_TAG:
required: false
type: string
env:
REGISTRY: ghcr.io
jobs:
build:
name: Build Image
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v3
# This only gets the date in this job, because
# there is no release tag
- name: Get release info
id: release_info
run: |
echo "date=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT
echo ""
- name: Build & Push Docker image
uses: docker/build-push-action@v5
with:
context: ${{ inputs.BUILD_DIR }}
file: ${{ inputs.BUILD_DIR }}/Dockerfile
# These arguments get passed into the docker image itself
build-args: |
TX_DOCKER_VERSION=${{ github.sha }}
TX_RELEASE_TAG=dev-${{ steps.release_info.outputs.date }}
TX_RELEASE_DATE=${{ steps.release_info.outputs.date }}
push: true
# We use three tags for release builds:
# txpipe-dev
# txpipe-dev:latest
# txpipe-dev:<the date, e.g. 2023-03-21>
tags: ${{ inputs.EXTRA_TAG }}${{ inputs.PUSH_TAG }},${{ inputs.PUSH_TAG }}:latest,${{ inputs.PUSH_TAG }}:${{ steps.release_info.outputs.date }},${{ inputs.PUSH_TAG }}:${{ github.sha }}
cache-from: type=gha
cache-to: type=gha,mode=max