-
-
Notifications
You must be signed in to change notification settings - Fork 3
108 lines (100 loc) · 3.25 KB
/
ci.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
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
name: Build
on:
pull_request:
workflow_dispatch:
jobs:
get-matrix:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: output matrix
id: set-matrix
run: bash .github/scripts/get-matrix.sh
build:
needs: get-matrix
if: "!contains(github.event.head_commit.message, 'skip-build')"
name: Build
strategy:
fail-fast: false
matrix: ${{fromJson(needs.get-matrix.outputs.matrix)}}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Prep
id: prep
run: bash .github/scripts/prep-environment.sh
env:
PLATFORM: ${{ matrix.platform }}
TAGS: ${{ matrix.tags }}
FILE: ${{ matrix.file }}
- name: Set up Docker Buildx
if: steps.prep.outcome == 'success'
uses: docker/setup-buildx-action@v2
- name: Set up QEMU
if: steps.prep.outcome == 'success'
uses: docker/setup-qemu-action@v2
- name: Cache Docker layers
if: steps.prep.outcome == 'success'
uses: actions/cache@v3
with:
path: /tmp/.buildx-cache
key: "${{ steps.prep.outputs.key }}-buildx-${{ github.sha }}-20220222"
restore-keys: "${{ steps.prep.outputs.key }}-buildx-${{ github.sha }}-20220222"
- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.docker_username }}
password: ${{ secrets.docker_password }}
- name: Build Multiarch
if: matrix.platform == 'multi' && steps.prep.outcome == 'success'
uses: docker/build-push-action@v3
with:
push: true
file: ./Dockerfile_${{ matrix.file }}
platforms: ${{ steps.prep.outputs.multi }}
tags: ${{ steps.prep.outputs.tags }}
build-args: ${{ matrix.build_args }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache
- name: Build specific arch
if: matrix.platform != 'multi' && steps.prep.outcome == 'success'
uses: docker/build-push-action@v3
with:
push: true
file: ./Dockerfile_${{ matrix.file }}
platforms: ${{ matrix.platform }}
tags: ${{ steps.prep.outputs.ptags }}
build-args: ${{ matrix.build_args }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache
description:
runs-on: ubuntu-latest
name: Description
needs: [build]
strategy:
matrix:
repository: [shivammathur/node, setupphp/node]
steps:
- uses: actions/checkout@v4
- name: Docker Hub Description
uses: peter-evans/dockerhub-description@v3
with:
username: ${{ secrets.docker_username }}
password: ${{ secrets.docker_password }}
repository: ${{ matrix.repository }}
results:
if: ${{ always() }}
runs-on: ubuntu-latest
name: Final Results
needs: [build]
steps:
- run: exit 1
if: >-
${{
contains(needs.*.result, 'failure')
|| contains(needs.*.result, 'cancelled')
}}