diff --git a/.github/buildbot-version b/.github/buildbot-version new file mode 100644 index 0000000..b6d8b76 --- /dev/null +++ b/.github/buildbot-version @@ -0,0 +1 @@ +3.11.8 diff --git a/.github/workflows/build-push.yml b/.github/workflows/build-push.yml index 31f3920..c9f07c6 100644 --- a/.github/workflows/build-push.yml +++ b/.github/workflows/build-push.yml @@ -14,7 +14,6 @@ on: type: number env: - BUILDBOT_VERSION: 3.11.8 GITHUB_SHA_LEN: 8 concurrency: @@ -77,17 +76,27 @@ jobs: - name: Environment variables run: | - echo "GIT_SHA_SHORT=${GITHUB_SHA::${{ env.GITHUB_SHA_LEN }}}" >> $GITHUB_ENV + echo "BUILDBOT_VERSION=$(cat .github/buildbot-version)" >> $GITHUB_ENV + echo "GIT_SHA_SHORT=$(git rev-parse --short=${{ env.GITHUB_SHA_LEN }} HEAD)" >> $GITHUB_ENV + if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then + echo "CONTAINER_TAG=pr-${{ inputs.pr_number }}" >> $GITHUB_ENV + elif [ "${{ startsWith(github.ref, 'refs/tags/') }}" = "true" ]; then + echo "CONTAINER_TAG=${{ github.ref_name }}" >> $GITHUB_ENV + else + echo "CONTAINER_TAG=${{ github.ref_name }}" >> $GITHUB_ENV + fi - name: Build container and export it to local Docker uses: docker/build-push-action@v6 with: + context: . load: true tags: local/${{ matrix.container_flavor }} file: docker/build${{ matrix.container_flavor }}/Dockerfile build-args: | BUILDBOT_VERSION=${{ env.BUILDBOT_VERSION }} - OPENWRT_VERSION=${{ env.GIT_SHA_SHORT }} + BUILDBOT_CONFIG_SHA=${{ env.GIT_SHA_SHORT }} + CONTAINER_TAG=${{ env.CONTAINER_TAG }} - name: Test ${{ matrix.container_flavor }} Docker container run: | @@ -121,7 +130,15 @@ jobs: - name: Environment variables run: | - echo "GIT_SHA_SHORT=${GITHUB_SHA::${{ env.GITHUB_SHA_LEN }}}" >> $GITHUB_ENV + echo "BUILDBOT_VERSION=$(cat .github/buildbot-version)" >> $GITHUB_ENV + echo "GIT_SHA_SHORT=$(git rev-parse --short=${{ env.GITHUB_SHA_LEN }} HEAD)" >> $GITHUB_ENV + if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then + echo "CONTAINER_TAG=pr-${{ inputs.pr_number }}" >> $GITHUB_ENV + elif [ "${{ startsWith(github.ref, 'refs/tags/') }}" = "true" ]; then + echo "CONTAINER_TAG=${{ github.ref_name }}" >> $GITHUB_ENV + else + echo "CONTAINER_TAG=${{ github.ref_name }}" >> $GITHUB_ENV + fi - name: Docker meta id: meta @@ -130,7 +147,7 @@ jobs: images: ghcr.io/${{ github.repository }}/build${{ matrix.container_flavor }}-v${{ env.BUILDBOT_VERSION }} tags: | type=raw,value=pr-${{ inputs.pr_number }},enable=${{ github.event_name == 'workflow_dispatch' }} - type=ref,event=branch + type=ref,event=branch,enable=${{ github.event_name != 'workflow_dispatch' }} type=sha,prefix=sha-,enable=${{ github.event_name != 'workflow_dispatch' }} type=semver,pattern={{version}} @@ -144,10 +161,12 @@ jobs: - name: Build container again and push it uses: docker/build-push-action@v6 with: + context: . push: true tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} file: docker/build${{ matrix.container_flavor }}/Dockerfile build-args: | BUILDBOT_VERSION=${{ env.BUILDBOT_VERSION }} - OPENWRT_VERSION=${{ env.GIT_SHA_SHORT }} + BUILDBOT_CONFIG_SHA=${{ env.GIT_SHA_SHORT }} + CONTAINER_TAG=${{ env.CONTAINER_TAG }} diff --git a/.github/workflows/cleanup-pr-containers.yml b/.github/workflows/cleanup-pr-containers.yml index 073b4b8..ddef073 100644 --- a/.github/workflows/cleanup-pr-containers.yml +++ b/.github/workflows/cleanup-pr-containers.yml @@ -4,9 +4,6 @@ on: pull_request: types: [closed] -env: - BUILDBOT_VERSION: 3.11.8 - jobs: cleanup: name: Delete PR container images @@ -21,6 +18,12 @@ jobs: - worker steps: + - name: Checkout + uses: actions/checkout@v5 + + - name: Read Buildbot version + run: echo "BUILDBOT_VERSION=$(cat .github/buildbot-version)" >> $GITHUB_ENV + - name: Delete PR container image uses: actions/delete-package-versions@v5 with: diff --git a/docker/buildmaster/Dockerfile b/docker/buildmaster/Dockerfile index 15899fd..9250e45 100644 --- a/docker/buildmaster/Dockerfile +++ b/docker/buildmaster/Dockerfile @@ -28,7 +28,7 @@ LABEL maintainer="OpenWrt Maintainers" ARG DEBIAN_FRONTEND=noninteractive ARG BUILDBOT_VERSION=2.10.1 -ARG OPENWRT_VERSION=unknown +ARG BUILDBOT_CONFIG_SHA=unknown ENV BUILDMASTER_CONFIG=config.ini ENV BUILDMASTER_PHASE=1 @@ -74,7 +74,7 @@ RUN \ RUN \ sed -i \ - "s;\"col-sm-12\">