-
Notifications
You must be signed in to change notification settings - Fork 73
81 lines (78 loc) · 3.04 KB
/
build_docker_image.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: Build Docker image
on: [push, pull_request]
jobs:
main:
name: Docker
runs-on: ubuntu-latest
timeout-minutes: 20
strategy:
matrix:
tag: [latest, debug, lto]
include:
- tag: latest
build-args: buildparams=CFLAGS=-O2 CXXFLAGS=-O2
- tag: debug
build-args: buildparams=DEBUG=y
- tag: lto
build-args: buildparams=LTO=y CFLAGS=-O2 CXXFLAGS=-O2
steps:
- name: Clone Tree
uses: actions/checkout@v3
with:
submodules: recursive
- name: Build Docker image
run: |
docker build --build-arg buildparams="${{ matrix.build-args }}" -t ${{ matrix.tag }} . \
--label "org.opencontainers.image.revision=${{ github.sha }}" \
--label "org.opencontainers.image.created=$(date --rfc-3339=seconds --utc)"
- name: Test Docker image
run: |
cd samples
for dir in */
do
cd "$dir"
docker run --rm -v `pwd`:/usr/src/app -t ${{ matrix.tag }} make -j`nproc`
cd ..
done
- name: Push container if on master branch
if: github.ref == 'refs/heads/master'
run: |
docker login -u "${{ github.actor }}" -p "${{ secrets.GITHUB_TOKEN }}" ghcr.io
docker tag ${{ matrix.tag }} ghcr.io/${{ github.repository }}:${{ matrix.tag }}
docker push ghcr.io/${{ github.repository }}:${{ matrix.tag }}
xboxdev_containers:
name: Push Official Containers
if: github.repository_owner == 'XboxDev' && github.ref == 'refs/heads/master'
needs: [main]
runs-on: ubuntu-latest
strategy:
matrix:
tag: [latest, debug, lto]
steps:
- name: Pull container
run: |
docker login -u "${{ github.actor }}" -p "${{ secrets.GITHUB_TOKEN }}" ghcr.io
docker pull ghcr.io/${{ github.repository }}:${{ matrix.tag }}
- name: Push to XboxDev group
run: |
if [ "${{ matrix.tag }}" == "latest" ]; then
TARGET="ghcr.io/${{ github.repository_owner }}/nxdk"
else
TARGET="ghcr.io/${{ github.repository_owner }}/nxdk-${{ matrix.tag }}"
fi
docker tag ghcr.io/${{ github.repository }}:${{ matrix.tag }} ${TARGET}:latest
docker tag ghcr.io/${{ github.repository }}:${{ matrix.tag }} ${TARGET}:git-${GITHUB_SHA::8}
docker push ${TARGET}:latest
docker push ${TARGET}:git-${GITHUB_SHA::8}
- name: Push to Docker Hub
run: |
docker login -u "${{ secrets.DOCKERHUB_USERNAME }}" -p "${{ secrets.DOCKERHUB_TOKEN }}"
if [ "${{ matrix.tag }}" == "latest" ]; then
TARGET="xboxdev/nxdk"
else
TARGET="xboxdev/nxdk-${{ matrix.tag }}"
fi
docker tag ghcr.io/${{ github.repository }}:${{ matrix.tag }} ${TARGET}:latest
docker tag ghcr.io/${{ github.repository }}:${{ matrix.tag }} ${TARGET}:git-${GITHUB_SHA::8}
docker push ${TARGET}:latest
docker push ${TARGET}:git-${GITHUB_SHA::8}