|
| 1 | +name: Continuous Integration |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - 'master' |
| 7 | + paths-ignore: |
| 8 | + - '**.md' |
| 9 | + pull_request: |
| 10 | + branches: |
| 11 | + - master |
| 12 | + types: |
| 13 | + - opened |
| 14 | + - reopened |
| 15 | + - synchronize |
| 16 | + paths-ignore: |
| 17 | + - '**.md' |
| 18 | + create: |
| 19 | + tags: |
| 20 | + - 'v[0-9]+.[0-9]+.[0-9]+*' |
| 21 | + |
| 22 | +env: |
| 23 | + DOCKER_BUILDKIT: 1 |
| 24 | + GOLANG_VERSION: 1.15 |
| 25 | + |
| 26 | +jobs: |
| 27 | + |
| 28 | + binary: |
| 29 | + name: Build Binary |
| 30 | + runs-on: ubuntu-18.04 |
| 31 | + steps: |
| 32 | + - name: Checkout Repository |
| 33 | + uses: actions/checkout@v2 |
| 34 | + - name: Fetch Cached Artifacts |
| 35 | + uses: actions/cache@v2 |
| 36 | + with: |
| 37 | + path: ${{ github.workspace }}/nginx-asg-sync |
| 38 | + key: nginx-asg-sync-${{ github.run_id }}-${{ github.run_number }} |
| 39 | + - name: Docker Buildx |
| 40 | + uses: docker/setup-buildx-action@v1 |
| 41 | + with: |
| 42 | + driver-opts: network=host |
| 43 | + - name: Cache Docker layers |
| 44 | + uses: actions/cache@v2 |
| 45 | + with: |
| 46 | + path: /tmp/.buildx-cache |
| 47 | + key: ${{ runner.os }}-buildx-${{ github.sha }} |
| 48 | + restore-keys: | |
| 49 | + ${{ runner.os }}-buildx- |
| 50 | + - name: Build Image |
| 51 | + uses: docker/build-push-action@v2 |
| 52 | + with: |
| 53 | + file: build/Dockerfile |
| 54 | + context: '.' |
| 55 | + target: builder |
| 56 | + cache-from: type=local,src=/tmp/.buildx-cache |
| 57 | + cache-to: type=local,dest=/tmp/.buildx-cache |
| 58 | + tags: nginx/nginx-asg-sync:${{ github.sha }} |
| 59 | + |
| 60 | + unit-tests: |
| 61 | + name: Unit Tests |
| 62 | + runs-on: ubuntu-18.04 |
| 63 | + steps: |
| 64 | + - name: Checkout Repository |
| 65 | + uses: actions/checkout@v2 |
| 66 | + - name: Setup Golang Environment |
| 67 | + uses: actions/setup-go@v2 |
| 68 | + with: |
| 69 | + go-version: '${{ env.GOLANG_VERSION }}' |
| 70 | + - name: Run Tests |
| 71 | + run: make test |
| 72 | + |
| 73 | + build: |
| 74 | + name: Build Image |
| 75 | + runs-on: ubuntu-18.04 |
| 76 | + needs: [binary, unit-tests] |
| 77 | + steps: |
| 78 | + - name: Checkout Repository |
| 79 | + uses: actions/checkout@v2 |
| 80 | + - name: Fetch Cached Artifacts |
| 81 | + uses: actions/cache@v2 |
| 82 | + with: |
| 83 | + path: ${{ github.workspace }}/nginx-asg-sync |
| 84 | + key: nginx-asg-sync-${{ github.run_id }}-${{ github.run_number }} |
| 85 | + - name: Docker Buildx |
| 86 | + uses: docker/setup-buildx-action@v1 |
| 87 | + with: |
| 88 | + driver-opts: network=host |
| 89 | + - name: Cache Docker layers |
| 90 | + uses: actions/cache@v2 |
| 91 | + with: |
| 92 | + path: /tmp/.buildx-cache |
| 93 | + key: ${{ runner.os }}-buildx-${{ github.sha }} |
| 94 | + restore-keys: | |
| 95 | + ${{ runner.os }}-buildx- |
| 96 | + - name: Build Image Amazon 1 |
| 97 | + uses: docker/build-push-action@v2 |
| 98 | + with: |
| 99 | + file: build/Dockerfile |
| 100 | + context: '.' |
| 101 | + target: rpm_based |
| 102 | + load: true |
| 103 | + cache-from: type=local,src=/tmp/.buildx-cache |
| 104 | + cache-to: type=local,dest=/tmp/.buildx-cache |
| 105 | + tags: amazon-builder:${{ github.sha }} |
| 106 | + build-args: | |
| 107 | + CONTAINER_VERSION=amazonlinux:1 |
| 108 | + - name: Run Amazon 1 |
| 109 | + uses: addnab/docker-run-action@v1 |
| 110 | + with: |
| 111 | + image: amazon-builder:${{ github.sha }} |
| 112 | + run: /build.sh |
| 113 | + options: -v ${{ github.workspace }}/build/package/rpm:/rpm -v ${{ github.workspace }}/build_output:/build_output |
| 114 | + - name: Build Image Amazon 2 |
| 115 | + uses: docker/build-push-action@v2 |
| 116 | + with: |
| 117 | + file: build/Dockerfile |
| 118 | + context: '.' |
| 119 | + target: rpm_based |
| 120 | + load: true |
| 121 | + cache-from: type=local,src=/tmp/.buildx-cache |
| 122 | + cache-to: type=local,dest=/tmp/.buildx-cache |
| 123 | + tags: amazon2-builder:${{ github.sha }} |
| 124 | + build-args: | |
| 125 | + CONTAINER_VERSION=amazonlinux:2 |
| 126 | + - name: Run Amazon 2 |
| 127 | + uses: addnab/docker-run-action@v1 |
| 128 | + with: |
| 129 | + image: amazon2-builder:${{ github.sha }} |
| 130 | + run: /build.sh |
| 131 | + options: -v ${{ github.workspace }}/build/package/rpm:/rpm -v ${{ github.workspace }}/build_output:/build_output |
| 132 | + - name: Build Image Centos 7 |
| 133 | + uses: docker/build-push-action@v2 |
| 134 | + with: |
| 135 | + file: build/Dockerfile |
| 136 | + context: '.' |
| 137 | + target: rpm_based |
| 138 | + load: true |
| 139 | + cache-from: type=local,src=/tmp/.buildx-cache |
| 140 | + cache-to: type=local,dest=/tmp/.buildx-cache |
| 141 | + tags: centos7-builder:${{ github.sha }} |
| 142 | + build-args: | |
| 143 | + CONTAINER_VERSION=centos:7 |
| 144 | + - name: Run Centos 7 |
| 145 | + uses: addnab/docker-run-action@v1 |
| 146 | + with: |
| 147 | + image: centos7-builder:${{ github.sha }} |
| 148 | + run: /build.sh |
| 149 | + options: -v ${{ github.workspace }}/build/package/rpm:/rpm -v ${{ github.workspace }}/build_output:/build_output |
| 150 | + - name: Build Image Ubuntu Xenial |
| 151 | + uses: docker/build-push-action@v2 |
| 152 | + with: |
| 153 | + file: build/Dockerfile |
| 154 | + context: '.' |
| 155 | + target: deb_based |
| 156 | + load: true |
| 157 | + cache-from: type=local,src=/tmp/.buildx-cache |
| 158 | + cache-to: type=local,dest=/tmp/.buildx-cache |
| 159 | + tags: ubuntu-xenial-builder:${{ github.sha }} |
| 160 | + build-args: | |
| 161 | + CONTAINER_VERSION=ubuntu:xenial |
| 162 | + OS_VERSION=xenial |
| 163 | + - name: Run Ubuntu Xenial |
| 164 | + uses: addnab/docker-run-action@v1 |
| 165 | + with: |
| 166 | + image: ubuntu-xenial-builder:${{ github.sha }} |
| 167 | + run: /build.sh |
| 168 | + options: -v ${{ github.workspace }}/build/package/debian:/debian -v ${{ github.workspace }}/build_output:/build_output |
| 169 | + - name: Build Image Ubuntu Bionic |
| 170 | + uses: docker/build-push-action@v2 |
| 171 | + with: |
| 172 | + file: build/Dockerfile |
| 173 | + context: '.' |
| 174 | + target: deb_based |
| 175 | + load: true |
| 176 | + cache-from: type=local,src=/tmp/.buildx-cache |
| 177 | + cache-to: type=local,dest=/tmp/.buildx-cache |
| 178 | + tags: ubuntu-bionic-builder:${{ github.sha }} |
| 179 | + build-args: | |
| 180 | + CONTAINER_VERSION=ubuntu:bionic |
| 181 | + OS_VERSION=bionic |
| 182 | + - name: Run Ubuntu Bionic |
| 183 | + uses: addnab/docker-run-action@v1 |
| 184 | + with: |
| 185 | + image: ubuntu-bionic-builder:${{ github.sha }} |
| 186 | + run: /build.sh |
| 187 | + options: -v ${{ github.workspace }}/build/package/debian:/debian -v ${{ github.workspace }}/build_output:/build_output |
| 188 | + - name: Build Image Ubuntu Focal |
| 189 | + uses: docker/build-push-action@v2 |
| 190 | + with: |
| 191 | + file: build/Dockerfile |
| 192 | + context: '.' |
| 193 | + target: deb_based |
| 194 | + load: true |
| 195 | + cache-from: type=local,src=/tmp/.buildx-cache |
| 196 | + cache-to: type=local,dest=/tmp/.buildx-cache |
| 197 | + tags: ubuntu-focal-builder:${{ github.sha }} |
| 198 | + build-args: | |
| 199 | + CONTAINER_VERSION=ubuntu:focal |
| 200 | + OS_VERSION=focal |
| 201 | + - name: Run Ubuntu Focal |
| 202 | + uses: addnab/docker-run-action@v1 |
| 203 | + with: |
| 204 | + image: ubuntu-focal-builder:${{ github.sha }} |
| 205 | + run: /build.sh |
| 206 | + options: -v ${{ github.workspace }}/build/package/debian:/debian -v ${{ github.workspace }}/build_output:/build_output |
| 207 | + - name: Build Image Ubuntu Groovy |
| 208 | + uses: docker/build-push-action@v2 |
| 209 | + with: |
| 210 | + file: build/Dockerfile |
| 211 | + context: '.' |
| 212 | + target: deb_based |
| 213 | + load: true |
| 214 | + cache-from: type=local,src=/tmp/.buildx-cache |
| 215 | + cache-to: type=local,dest=/tmp/.buildx-cache |
| 216 | + tags: ubuntu-groovy-builder:${{ github.sha }} |
| 217 | + build-args: | |
| 218 | + CONTAINER_VERSION=ubuntu:groovy |
| 219 | + OS_VERSION=groovy |
| 220 | + - name: Run Ubuntu Groovy |
| 221 | + uses: addnab/docker-run-action@v1 |
| 222 | + with: |
| 223 | + image: ubuntu-groovy-builder:${{ github.sha }} |
| 224 | + run: /build.sh |
| 225 | + options: -v ${{ github.workspace }}/build/package/debian:/debian -v ${{ github.workspace }}/build_output:/build_output |
0 commit comments