aboutsummaryrefslogtreecommitdiff
path: root/.github/workflows/devel.yml
blob: f32fe9c42a970cd99e7be5584ef6677836b73fcd (plain)
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
name: devel
on:
  pull_request:
  push:
    branches:
    - master
    - staging
    - trying

env:
  DOCKER_IMAGE: localhost:5000/github.com/joseluisq/alpine-cgit

jobs:
  docker-alpine:
    name: Docker test
    strategy:
      matrix:
        arch:
          - linux/amd64
          - linux/386
          - linux/arm64
          - linux/arm/v7
          - linux/arm/v6
    runs-on: ubuntu-20.04
    services:
      registry:
        image: registry:2
        ports:
          - 5000:5000
    steps:
      -
        name: Checkout
        uses: actions/checkout@v3
        with:
          fetch-depth: 1
      -
        name: Cache Docker layers
        uses: actions/cache@v2
        with:
          path: /tmp/.buildx-cache
          key: static-web-server-${{ matrix.arch }}-buildx-${{ github.sha }}
          restore-keys: |
            static-web-server-${{ matrix.arch }}-buildx-
      -
        name: Set up QEMU
        uses: docker/setup-qemu-action@v2
      -
        name: Docker meta alpine
        id: meta_alpine
        uses: docker/metadata-action@v3
        with:
          images: ${{ env.DOCKER_IMAGE }}
          flavor: |
            latest=true
          tags: |
            type=schedule
            type=ref,event=branch
            type=ref,event=pr
            type=semver,pattern={{version}}
            type=semver,pattern={{major}}.{{minor}}
            type=semver,pattern={{major}}
            type=sha
      -
        name: Set up Docker Buildx
        uses: docker/setup-buildx-action@v2
        with:
          driver-opts: network=host
      -
        name: Build and export to Docker client
        uses: docker/build-push-action@v3
        with:
          context: .
          platforms: ${{ matrix.arch }}
          file: Dockerfile
          load: true
          tags: ${{ steps.meta_alpine.outputs.tags }}
          labels: ${{ steps.meta_alpine.outputs.labels }}
      -
        name: Build and push to local registry
        uses: docker/build-push-action@v3
        with:
          context: .
          platforms: ${{ matrix.arch }}
          file: Dockerfile
          push: ${{ github.event_name != 'pull_request' }}
          tags: ${{ steps.meta_alpine.outputs.tags }}
          labels: ${{ steps.meta_alpine.outputs.labels }}
          cache-from: type=local,src=/tmp/.buildx-cache
          cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max
      -
        name: Test
        uses: addnab/docker-run-action@v1
        with:
          image: ${{ env.DOCKER_IMAGE }}
          options: -v ${{ github.workspace }}:/cgit
          run: |
            uname -a
            apk info cgit
            nginx -v
            cat /etc/os-release
      -
        name: Inspect image
        run: |
          docker image inspect ${{ env.DOCKER_IMAGE }}:${{ steps.meta_alpine.outputs.version }}
      -
        name: Check manifest
        if: github.event_name != 'pull_request'
        run: |
          docker buildx imagetools inspect ${{ env.DOCKER_IMAGE }}:${{ steps.meta_alpine.outputs.version }}
      -
        # Temp fix
        # https://github.com/docker/build-push-action/issues/252
        # https://github.com/moby/buildkit/issues/1896
        name: Move cache
        run: |
          rm -rf /tmp/.buildx-cache
          mv /tmp/.buildx-cache-new /tmp/.buildx-cache