-
Notifications
You must be signed in to change notification settings - Fork 1
117 lines (102 loc) · 3.84 KB
/
Copy pathrelease-node-runtime-image.yml
File metadata and controls
117 lines (102 loc) · 3.84 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
107
108
109
110
111
112
113
114
115
116
117
name: Publish Runtime Images
on:
workflow_dispatch:
inputs:
tag:
description: "Optional version tag (defaults to package.json version)"
required: false
include_latest:
description: "Also publish :latest"
required: false
default: "true"
push:
tags:
- "v*"
jobs:
publish:
runs-on: blacksmith-4vcpu-ubuntu-2404
permissions:
contents: read
packages: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Bun
uses: oven-sh/setup-bun@v1
with:
bun-version: "1.3.9"
- name: Setup QEMU
uses: docker/setup-qemu-action@v3
- name: Setup Blacksmith Builder
uses: useblacksmith/setup-docker-builder@v1
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
registry: docker.io
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Login to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Resolve image tags
id: tags
env:
EVENT_NAME: ${{ github.event_name }}
INPUT_TAG: ${{ github.event.inputs.tag }}
INPUT_INCLUDE_LATEST: ${{ github.event.inputs.include_latest }}
run: |
set -euo pipefail
if [ -n "${INPUT_TAG}" ]; then
VERSION="${INPUT_TAG#v}"
elif [ "${EVENT_NAME}" = "push" ] && [ "${GITHUB_REF_TYPE}" = "tag" ]; then
VERSION="${GITHUB_REF_NAME#v}"
else
VERSION="$(bun -e "const pkg = await Bun.file('package.json').json(); console.log(pkg.version)")"
fi
if [ -z "${VERSION}" ]; then
echo "Unable to resolve image version."
exit 1
fi
DOCKERHUB_IMAGE="docker.io/hackdance/hack"
GHCR_IMAGE="ghcr.io/${{ github.repository_owner }}/hack"
FULL_TAG_ARGS="--tag ${DOCKERHUB_IMAGE}:${VERSION} --tag ${GHCR_IMAGE}:${VERSION}"
SLIM_TAG_ARGS="--tag ${DOCKERHUB_IMAGE}:${VERSION}-slim --tag ${GHCR_IMAGE}:${VERSION}-slim"
if [ "${EVENT_NAME}" = "push" ] || [ "${INPUT_INCLUDE_LATEST}" = "true" ]; then
FULL_TAG_ARGS="${FULL_TAG_ARGS} --tag ${DOCKERHUB_IMAGE}:latest --tag ${GHCR_IMAGE}:latest"
SLIM_TAG_ARGS="${SLIM_TAG_ARGS} --tag ${DOCKERHUB_IMAGE}:slim --tag ${GHCR_IMAGE}:slim"
fi
{
echo "version=${VERSION}"
echo "dockerhub_image=${DOCKERHUB_IMAGE}"
echo "ghcr_image=${GHCR_IMAGE}"
echo "full_tag_args=${FULL_TAG_ARGS}"
echo "slim_tag_args=${SLIM_TAG_ARGS}"
} >> "$GITHUB_OUTPUT"
- name: Build and push full runtime image
run: |
bun run scripts/build-node-runtime-image.ts \
--variant node-runtime \
--push \
--platform linux/amd64,linux/arm64 \
${{ steps.tags.outputs.full_tag_args }}
- name: Build and push slim runtime image
run: |
bun run scripts/build-node-runtime-image.ts \
--variant slim \
--push \
--platform linux/amd64,linux/arm64 \
${{ steps.tags.outputs.slim_tag_args }}
- name: Summary
run: |
{
echo "### Runtime images published"
echo ""
echo "- Version: \`${{ steps.tags.outputs.version }}\`"
echo "- Docker Hub repo: \`${{ steps.tags.outputs.dockerhub_image }}\`"
echo "- GHCR repo: \`${{ steps.tags.outputs.ghcr_image }}\`"
echo "- Full tags: \`${{ steps.tags.outputs.full_tag_args }}\`"
echo "- Slim tags: \`${{ steps.tags.outputs.slim_tag_args }}\`"
} >> "$GITHUB_STEP_SUMMARY"