about summary refs log tree commit diff
path: root/.github/workflows/container.yml
blob: 8836997d2aae29f7a1db73273279886d94d49786 (plain) (blame)
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
name: Container
on:
  push:
    branches:
      - stable
      - dev
    tags:
      - "*"
  pull_request:
    branches:
      - dev # No need for stable-pull-request, as that equals dev-push

jobs:
  build-and-test-amd64:
    name: Test amd64 image
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v3
      - name: Set up Docker Buildx
        uses: docker/setup-buildx-action@v2
      - name: Build amd64
        uses: docker/build-push-action@v3
        with:
          context: .
          tags: aflplusplus:test-amd64
          load: true
          cache-to: type=gha,mode=max
          build-args: |
            TEST_BUILD=1
      - name: Test amd64
        run: >
          docker run --rm aflplusplus:test-amd64 bash -c "
          apt-get update && 
          apt-get install -y libcmocka-dev && 
          make -i tests
          "

  push:
    name: Push amd64 and arm64 images
    runs-on: ubuntu-latest
    needs:
      - build-and-test-amd64
    if: ${{ github.event_name == 'push' && github.repository == 'AFLplusplus/AFLplusplus' }}
    steps:
      - name: Checkout
        uses: actions/checkout@v3
      - name: Set up QEMU
        uses: docker/setup-qemu-action@v2
        with:
          platforms: arm64
      - name: Set up Docker Buildx
        uses: docker/setup-buildx-action@v2
      - name: Login to docker.io
        uses: docker/login-action@v2
        with:
          username: ${{ secrets.DOCKER_USERNAME }}
          password: ${{ secrets.DOCKER_TOKEN }}
      - name: Set tags to push
        id: push-tags
        run: |
          PUSH_TAGS=docker.io/aflplusplus/aflplusplus:${GITHUB_REF_NAME}
          if [ "${GITHUB_REF_NAME}" = "stable" ]; then
            PUSH_TAGS=${PUSH_TAGS},docker.io/aflplusplus/aflplusplus:latest
          fi
          export PUSH_TAGS
          echo "::set-output name=PUSH_TAGS::${PUSH_TAGS}"
      - name: Push to docker.io registry
        uses: docker/build-push-action@v3
        with:
          context: .
          platforms: linux/amd64,linux/arm64
          push: true
          tags: ${{ steps.push-tags.outputs.PUSH_TAGS }}
          cache-from: type=gha