1 name: Build and push containers
11 BUILDBOT_VERSION: 3.8.0
15 group: ${{ github.workflow }}-${{ github.ref }}
16 cancel-in-progress: ${{ github.event_name == 'pull_request' }}
20 name: Test with Python ${{ matrix.python-version }}
21 runs-on: ubuntu-latest
31 uses: actions/checkout@v3
33 - uses: actions/setup-python@v4
35 python-version: ${{ matrix.python-version }}
37 - name: Install dependencies
38 run: pip install -r requirements-dev.txt
40 - name: Lint with ruff
41 run: ruff phase*/master.cfg
43 - name: Stylecheck with black
44 run: black phase1/master.cfg
47 name: Build, test and push containers
48 runs-on: ubuntu-latest
55 fail-fast: ${{ github.event_name == 'pull_request' }}
63 uses: actions/checkout@v3
65 - name: Environment variables
67 echo "GIT_SHA_SHORT=${GITHUB_SHA::${{ env.GITHUB_SHA_LEN }}}" >> $GITHUB_ENV
69 - name: Build container and export it to local Docker
70 uses: docker/build-push-action@v4
73 tags: local/${{ matrix.container_flavor }}
74 file: docker/build${{ matrix.container_flavor }}/Dockerfile
76 BUILDBOT_VERSION=${{ env.BUILDBOT_VERSION }}
77 OPENWRT_VERSION=${{ env.GIT_SHA_SHORT }}
79 - name: Test master Docker container
80 if: matrix.container_flavor == 'master'
82 docker run --detach --name test-master local/master
84 docker logs test-master | tee master.log
85 grep "buildmaster configured in /master" master.log
87 - name: Test worker Docker container
88 if: matrix.container_flavor == 'worker'
90 docker run --detach --env BUILDWORKER_NAME=X --env BUILDWORKER_PASSWORD=Y --name test-worker local/worker
92 docker logs test-worker | tee worker.log
93 grep "worker configured in /builder" worker.log
97 if: github.event_name != 'pull_request' || github.repository_owner != 'openwrt'
98 uses: docker/metadata-action@v4
100 images: name=ghcr.io/${{ github.repository }}/build${{ matrix.container_flavor }}-v${{ env.BUILDBOT_VERSION }}
102 - name: Login to GitHub Container Registry
103 uses: docker/login-action@v2
104 if: github.event_name != 'pull_request' || github.repository_owner != 'openwrt'
107 username: ${{ github.actor }}
108 password: ${{ secrets.GITHUB_TOKEN }}
110 - name: Build container again and push it
111 uses: docker/build-push-action@v4
112 if: github.event_name != 'pull_request' || github.repository_owner != 'openwrt'
115 tags: ${{ steps.meta.outputs.tags }}
116 labels: ${{ steps.meta.outputs.labels }}
117 file: docker/build${{ matrix.container_flavor }}/Dockerfile
119 BUILDBOT_VERSION=${{ env.BUILDBOT_VERSION }}
120 OPENWRT_VERSION=${{ env.GIT_SHA_SHORT }}