1 name: Build and push containers
11 BUILDBOT_VERSION: 3.8.0
14 group: ${{ github.workflow }}-${{ github.ref }}
15 cancel-in-progress: ${{ github.event_name == 'pull_request' }}
19 name: Build, test and push containers
20 runs-on: ubuntu-latest
26 fail-fast: ${{ github.event_name == 'pull_request' }}
34 uses: actions/checkout@v3
36 - name: Environment variables
38 echo "GIT_SHA_SHORT=${GITHUB_SHA::8}" >> $GITHUB_ENV
40 - name: Build container and export it to local Docker
41 uses: docker/build-push-action@v4
44 tags: local/${{ matrix.container_flavor }}
45 file: docker/build${{ matrix.container_flavor }}/Dockerfile
47 BUILDBOT_VERSION=${{ env.BUILDBOT_VERSION }}
48 OPENWRT_VERSION=${{ env.GIT_SHA_SHORT }}
50 - name: Test master Docker container
51 if: matrix.container_flavor == 'master'
53 docker run --detach --name test-master local/master
55 docker logs test-master | tee master.log
56 grep "buildmaster configured in /master" master.log
58 - name: Test worker Docker container
59 if: matrix.container_flavor == 'worker'
61 docker run --detach --env BUILDWORKER_NAME=X --env BUILDWORKER_PASSWORD=Y --name test-worker local/worker
63 docker logs test-worker | tee worker.log
64 grep "worker configured in /builder" worker.log
68 if: github.event_name != 'pull_request' || github.repository_owner != 'openwrt'
69 uses: docker/metadata-action@v4
71 images: name=ghcr.io/${{ github.repository }}/build${{ matrix.container_flavor }}-v${{ env.BUILDBOT_VERSION }}
73 - name: Login to GitHub Container Registry
74 uses: docker/login-action@v2
75 if: github.event_name != 'pull_request' || github.repository_owner != 'openwrt'
78 username: ${{ github.actor }}
79 password: ${{ secrets.GITHUB_TOKEN }}
81 - name: Build container again and push it
82 uses: docker/build-push-action@v4
83 if: github.event_name != 'pull_request' || github.repository_owner != 'openwrt'
86 tags: ${{ steps.meta.outputs.tags }}
87 labels: ${{ steps.meta.outputs.labels }}
88 file: docker/build${{ matrix.container_flavor }}/Dockerfile
90 BUILDBOT_VERSION=${{ env.BUILDBOT_VERSION }}
91 OPENWRT_VERSION=${{ env.GIT_SHA_SHORT }}