-
Notifications
You must be signed in to change notification settings - Fork 1
106 lines (90 loc) · 3.28 KB
/
Copy pathbuild-push.yaml
File metadata and controls
106 lines (90 loc) · 3.28 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
101
102
103
104
105
106
name: Build and Push Container Image
on:
workflow_dispatch:
inputs:
version:
description: 'Version tag (e.g. v1.17.0). Leave empty to tag only with SHA + latest.'
required: false
type: string
tinycode_ref:
description: 'tinycode git ref to build (branch, tag, or SHA). Default: main'
required: false
default: 'main'
type: string
env:
REGISTRY: ghcr.io
IMAGE_NAME: bobbyjohnstx/tinycode-container
jobs:
build-push:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7
- name: Set up QEMU
uses: docker/setup-qemu-action@06116385d9baf250c9f4dcb4858b16962ea869c3 # v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@37fe631027851001ddb9b187196cc803df7f5f0e # v4
- name: Log in to GHCR
uses: docker/login-action@650006c6eb7dba73a995cc03b0b2d7f5ca915bee # v4
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Check Quay.io credentials
id: quay
run: |
if [ -n "$QUAY_USER" ] && [ -n "$QUAY_PASS" ]; then
echo "available=true" >> "$GITHUB_OUTPUT"
else
echo "available=false" >> "$GITHUB_OUTPUT"
echo "::notice::Quay.io credentials not configured — skipping Quay push"
fi
env:
QUAY_USER: ${{ secrets.QUAY_USERNAME }}
QUAY_PASS: ${{ secrets.QUAY_PASSWORD }}
- name: Login to Quay.io
if: steps.quay.outputs.available == 'true'
uses: docker/login-action@650006c6eb7dba73a995cc03b0b2d7f5ca915bee # v4
with:
registry: quay.io
username: ${{ secrets.QUAY_USERNAME }}
password: ${{ secrets.QUAY_PASSWORD }}
- name: Compute image tags
id: tags
run: |
TAGS="${REGISTRY}/${IMAGE_NAME}:${GITHUB_SHA}"
TAGS="${TAGS},${REGISTRY}/${IMAGE_NAME}:latest"
if [ -n "$VERSION" ]; then
TAGS="${TAGS},${REGISTRY}/${IMAGE_NAME}:${VERSION}"
fi
if [ "$QUAY_AVAILABLE" = "true" ]; then
TAGS="${TAGS},quay.io/${IMAGE_NAME}:${GITHUB_SHA}"
TAGS="${TAGS},quay.io/${IMAGE_NAME}:latest"
if [ -n "$VERSION" ]; then
TAGS="${TAGS},quay.io/${IMAGE_NAME}:${VERSION}"
fi
fi
echo "tags=${TAGS}" >> "$GITHUB_OUTPUT"
env:
VERSION: ${{ inputs.version }}
QUAY_AVAILABLE: ${{ steps.quay.outputs.available }}
- name: Build and push multi-arch image
uses: docker/build-push-action@f9f3042f7e2789586610d6e8b85c8f03e5195baf # v7
with:
context: .
file: ContainerFile
platforms: linux/amd64,linux/arm64
push: true
build-args: |
TINYCODE_REF=${{ inputs.tinycode_ref || 'main' }}
tags: ${{ steps.tags.outputs.tags }}
- name: Smoke test (amd64)
run: |
docker run --rm --platform linux/amd64 --entrypoint tinycode \
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }} --version
- name: Smoke test (arm64)
run: |
docker run --rm --platform linux/arm64 --entrypoint tinycode \
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }} --version