-
Notifications
You must be signed in to change notification settings - Fork 0
134 lines (118 loc) · 5.78 KB
/
fill_station_action.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
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
name: Create and publish the Fill Station Docker image
# Configures this workflow to run every time a change is pushed to the branch called `main` or a pull request to `main` is created
on:
push:
branches: ['main']
pull_request:
# Defines two custom environment variables for the workflow. These are used for the Container registry domain, and a name for the Docker image that this workflow builds.
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository_owner }}/fill-station
jobs:
build-and-test:
runs-on: ubuntu-latest
strategy:
matrix:
arch: [amd64, arm64]
steps:
- name: Prepare
run: |
platform=linux/${{ matrix.arch }}
echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV
# Checks-out your repository under $GITHUB_WORKSPACE, which is the CWD for
# the rest of the steps
- name: Checkout code
uses: actions/checkout@v4
- uses: bazel-contrib/[email protected]
with:
# Avoid downloading Bazel every time.
bazelisk-cache: true
# Store build cache per workflow.
disk-cache: ${{ github.workflow }}-${{ matrix.arch }}
# Share repository cache between workflows.
repository-cache: true
# test for amd64 (can't test for arm64)
- name: Build and Test with Bazel
run: |
if [[ "${{ matrix.arch }}" == "amd64" ]]; then
bazel build //fill/lib/MockWiringPi:mock_wiringpi
./fill/setup_mock_wiringpi.sh
bazel build //fill:all
./fill/test/bv_test.sh
./fill/test/qd_test.sh
./fill/test/sv1_test.sh
elif [[ "${{ matrix.arch }}" == "arm64" ]]; then
sudo apt-get install g++-11-arm-linux-gnueabihf
sudo apt install gcc-11-arm-linux-gnueabihf
bazel build //fill/lib/MockWiringPi:mock_wiringpi --platforms=platform:rpi4 --cpu="aarch64"
./fill/setup_mock_wiringpi.sh "--platforms=platform:rpi4 --cpu="aarch64""
bazel build //fill:all --platforms=platform:rpi4 --cpu="aarch64"
fi
sudo mkdir -p ./fill/output
sudo cp bazel-bin/fill/fill_station ./fill/output
sudo cp fill/lib/libwiringPi.so ./fill/output
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
with:
platforms: all
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
# Uses the `docker/login-action` action to log in to the Container registry registry using the account and password that will publish the packages. Once published, the packages are scoped to the account defined here.
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# This step uses [docker/metadata-action](https://github.com/docker/metadata-action#about) to extract tags and labels that will be applied to the specified image. The `id` "meta" allows the output of this step to be referenced in a subsequent step. The `images` value provides the base name for the tags and labels.
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-${{ matrix.arch }}
tags: |
type=raw,value=latest,enable={{is_default_branch}}
type=ref,event=branch,enable=${{ github.ref != 'refs/heads/main' }}
type=ref,event=pr
- name: Build and push Fill Station Docker image by digest
id: build
uses: docker/build-push-action@v6
with:
context: .
file: fill/GithubDockerfile
platforms: linux/${{ matrix.arch }}
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
build-args: |
TARGETARCH=${{ matrix.arch }}
merge:
needs: build-and-test
runs-on: ubuntu-latest
steps:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
# Uses the `docker/login-action` action to log in to the Container registry registry using the account and password that will publish the packages. Once published, the packages are scoped to the account defined here.
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# This step uses [docker/metadata-action](https://github.com/docker/metadata-action#about) to extract tags and labels that will be applied to the specified image. The `id` "meta" allows the output of this step to be referenced in a subsequent step. The `images` value provides the base name for the tags and labels.
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
tags: |
type=raw,value=latest,enable={{is_default_branch}}
type=ref,event=branch,enable=${{ github.ref != 'refs/heads/main' }}
type=ref,event=pr
- name: Create manifest list and push
run: |
docker buildx imagetools create --tag ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.meta.outputs.tags }} ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-amd64:${{ steps.meta.outputs.tags }} ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-arm64:${{ steps.meta.outputs.tags }}
- name: Inspect image
run: |
docker buildx imagetools inspect ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.meta.outputs.tags }}