-
Notifications
You must be signed in to change notification settings - Fork 3
81 lines (67 loc) · 2.61 KB
/
ci-cd.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
75
76
77
78
79
80
81
name: CI/CD
on:
push:
workflow_dispatch:
schedule:
- cron: '0 0 * * 0'
jobs:
build:
strategy:
matrix:
version: [18, 20, 22]
runs-on: [ubuntu-latest, buildjet-4vcpu-ubuntu-2204-arm]
runs-on: ${{ matrix.runs-on }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Cache Docker layers
uses: actions/cache@v4
with:
path: /tmp/.buildx-cache
key: docker-buildx-${{ matrix.version }}-${{ github.sha }}
restore-keys: docker-buildx-${{ matrix.version }}-
- name: Build
run: |
docker buildx build \
--cache-from type=local,src=/tmp/.buildx-cache/${{ matrix.version }} \
--cache-to type=local,dest=/tmp/.buildx-cache/${{ matrix.version }} \
--output type=docker \
--tag kooldev/node:${{ matrix.version }}-$(arch) \
${{ matrix.version }}
- name: Tests
run: |
docker run kooldev/node:${{ matrix.version }}-$(arch) node -v;
docker run kooldev/node:${{ matrix.version }}-$(arch) npm -v;
docker run kooldev/node:${{ matrix.version }}-$(arch) yarn -v;
docker run -e ASUSER=1000 kooldev/node:${{ matrix.version }}-$(arch) node -v;
docker run -e ASUSER=1000 kooldev/node:${{ matrix.version }}-$(arch) npm -v;
docker run -e ASUSER=1000 kooldev/node:${{ matrix.version }}-$(arch) yarn -v;
- name: Login to DockerHub
uses: docker/login-action@v3
if: github.ref == 'refs/heads/master' && github.repository == 'kool-dev/docker-node'
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Push to DockerHub
if: github.ref == 'refs/heads/master' && github.repository == 'kool-dev/docker-node'
run: |
docker push kooldev/node:${{ matrix.version }}-$(arch)
amend:
if: github.ref == 'refs/heads/master' && github.repository == 'kool-dev/docker-node'
needs: build
runs-on: ubuntu-latest
strategy:
matrix:
version: [18, 20, 22]
steps:
- uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- run: |
docker manifest create kooldev/node:${{ matrix.version }} \
--amend kooldev/node:${{ matrix.version }}-x86_64 \
--amend kooldev/node:${{ matrix.version }}-aarch64
docker manifest push kooldev/node:${{ matrix.version }}