-
Notifications
You must be signed in to change notification settings - Fork 1
148 lines (128 loc) · 4.4 KB
/
Copy pathupdate-current-image.yml
File metadata and controls
148 lines (128 loc) · 4.4 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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
name: Update Image
on:
schedule:
- cron: '30 0 * * *'
workflow_dispatch:
inputs:
node_version:
description: 'Node.js version to build (e.g., 20.10.0). Leave empty to auto-detect latest.'
required: false
type: string
env:
IMAGE_NAME: node-minimal
jobs:
check_version:
runs-on: ubuntu-latest
outputs:
NODE_VERSION: ${{ steps.get_version.outputs.NODE_VERSION }}
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Validate and Get NODE_VERSION
id: get_version
run: |
if [[ -n "${{ github.event.inputs.node_version }}" ]]; then
INPUT_VERSION="${{ github.event.inputs.node_version }}"
if ! [[ $INPUT_VERSION =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "Error: Invalid version format '$INPUT_VERSION'. Expected format: X.Y.Z (e.g., 20.10.0)" >&2
exit 1
fi
echo "NODE_VERSION=$INPUT_VERSION" >> $GITHUB_OUTPUT
else
echo "NODE_VERSION=$(./check-missing-versions.sh | tail -1)" >> $GITHUB_OUTPUT
fi
echo "Building Node.js version: ${{ steps.get_version.outputs.NODE_VERSION }}"
build_push:
strategy:
matrix:
os:
- ubuntu-24.04
- ubuntu-24.04-arm
platform:
- amd64
- arm64
exclude:
- os: ubuntu-24.04
platform: arm64
- os: ubuntu-24.04-arm
platform: amd64
needs: check_version
runs-on: ${{ matrix.os }}
if: needs.check_version.outputs.NODE_VERSION
env:
NODE_VERSION: ${{needs.check_version.outputs.NODE_VERSION}}
steps:
- name: Checkout
uses: actions/checkout@v6
- name: ccache
uses: hendrikmuhs/ccache-action@v1.2
with:
key: ${{ matrix.os }}-${{ matrix.platform }}
max-size: 10G
- name: Configure ccache
run: |
ccache --set-config=sloppiness=time_macros,locale,include_file_ctime,include_file_mtime
ccache --set-config=hash_dir=false
ccache -p
- name: Set and Display Versions
run: |
MAJOR_VERSION=$(echo $NODE_VERSION | cut -d'.' -f 1)
echo "MAJOR_VERSION=$MAJOR_VERSION" >> $GITHUB_ENV
echo "Building Node.js version: $NODE_VERSION (major: $MAJOR_VERSION)"
- name: Build Node
run: |
export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH"
which gcc
./build.sh -n $NODE_VERSION
ccache -s
cp node-v$NODE_VERSION/out/Release/node node
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.CR_PAT }}
- name: Build
uses: docker/build-push-action@v6
env:
DOCKER_BUILD_SUMMARY: false
with:
context: .
platforms: linux/${{ matrix.platform }}
load: true
tags: ${{ env.IMAGE_NAME }}-${{ needs.check_version.outputs.NODE_VERSION }}
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Test Image
run: docker run --rm ${{ env.IMAGE_NAME }}-${{ needs.check_version.outputs.NODE_VERSION }} -e "console.log('Hello from Node.js ' + process.version)"
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
flavor: latest=true
images: ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.IMAGE_NAME }}, ghcr.io/chorrell/${{ env.IMAGE_NAME }}
tags: |
${{ env.NODE_VERSION }}
${{ env.MAJOR_VERSION }}
current
- name: Build and push Image
uses: docker/build-push-action@v6
with:
context: .
platforms: linux/${{ matrix.platform }}
push: true
provenance: mode=max
sbom: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max