diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 8952015a2..d6166a365 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -7,6 +7,12 @@ on: - 'release/*' tags: - 'v*.*' + pull_request: + paths: + - ".github/workflows/docker.yml" + - "tools/config_editor/requirements.txt" + - "tools/docker/Dockerfile" + - "tools/docker/entrypoint.sh" env: # Build the image for amd64 and arm64 @@ -16,8 +22,8 @@ env: jobs: docker: # Disable the job in forks - if: ${{ github.repository_owner == 'espressif' }} - + if: ${{ github.event_name == 'pull_request' || github.repository_owner == 'espressif' }} + name: Build docker image and push if needed runs-on: ubuntu-latest steps: # Depending on the branch/tag, set CLONE_BRANCH_OR_TAG variable (used in the Dockerfile @@ -29,50 +35,65 @@ jobs: run: | echo "CLONE_BRANCH_OR_TAG=$GITHUB_REF_NAME" >> $GITHUB_ENV echo "TAG_NAME=$GITHUB_REF_NAME" >> $GITHUB_ENV + echo "URL=${{ github.server_url }}/${{ github.repository }}.git" >> $GITHUB_ENV + - name: Set variables (release branches) if: ${{ github.ref_type == 'branch' && startsWith(github.ref_name, 'release/') }} run: | echo "CLONE_BRANCH_OR_TAG=$GITHUB_REF_NAME" >> $GITHUB_ENV echo "TAG_NAME=release-${GITHUB_REF_NAME##release/}" >> $GITHUB_ENV + echo "URL=${{ github.server_url }}/${{ github.repository }}.git" >> $GITHUB_ENV + - name: Set variables (main branch) if: ${{ github.ref_type == 'branch' && github.ref_name == 'master' }} run: | echo "CLONE_BRANCH_OR_TAG=master" >> $GITHUB_ENV echo "TAG_NAME=latest" >> $GITHUB_ENV + echo "URL=${{ github.server_url }}/${{ github.repository }}.git" >> $GITHUB_ENV + + - name: Set variables (pull requests) + if: ${{ github.event_name == 'pull_request' }} + run: | + echo "CLONE_BRANCH_OR_TAG=${{ github.event.pull_request.head.ref }}" >> $GITHUB_ENV + echo "TAG_NAME=PR_${{ github.event.number }}" >> $GITHUB_ENV + echo "URL=${{ github.server_url }}/${{ github.event.pull_request.head.repo.full_name }}.git" >> $GITHUB_ENV # Display the variables set above, just in case. - name: Check variables run: | echo "CLONE_BRANCH_OR_TAG: $CLONE_BRANCH_OR_TAG" - echo "CHECKOUT_REF: $CHECKOUT_REF" echo "TAG_NAME: $TAG_NAME" + echo "URL: $URL" - # The following steps are the standard boilerplate from - # https://github.com/marketplace/actions/build-and-push-docker-images - name: Checkout uses: actions/checkout@v4 + - name: Login to Docker Hub + if: ${{ github.event_name == 'push' }} uses: docker/login-action@v3 with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} + - name: Set up QEMU for multiarch builds uses: docker/setup-qemu-action@v3 + - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 + - name: Build and push uses: docker/build-push-action@v5 with: context: tools/docker - push: true + push: ${{ github.event_name == 'push' }} tags: ${{ env.DOCKERHUB_REPO }}:${{ env.TAG_NAME }} platforms: ${{ env.BUILD_PLATFORMS }} build-args: | - LIBBUILDER_CLONE_URL=${{ github.server_url }}/${{ github.repository }}.git + LIBBUILDER_CLONE_URL=${{ env.URL }} LIBBUILDER_CLONE_BRANCH_OR_TAG=${{ env.CLONE_BRANCH_OR_TAG }} - name: Update Docker Hub repository description (master branch) - if: ${{ github.ref_type == 'branch' && github.ref_name == 'master' }} + if: ${{ github.event_name == 'push' && github.ref_type == 'branch' && github.ref_name == 'master' }} uses: peter-evans/dockerhub-description@v4 with: username: ${{ secrets.DOCKERHUB_USERNAME }} diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index c3edd52d3..649c84c81 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -5,13 +5,21 @@ on: branches: - master pull_request: + paths: + - "**" + - "!**.md" + - "!.github/workflows/cron_build.yml" + - "!.github/workflows/cron.yml" + - "!.github/workflows/docker.yml" + - "!.github/workflows/repository_dispatch.yml" + - "!tools/config_editor/**" + - "!tools/docker/**" concurrency: group: esp-idf-libs-${{github.event.pull_request.number || github.ref}} cancel-in-progress: true jobs: - build-libs: name: Build Libs for ${{ matrix.target }} runs-on: ubuntu-latest @@ -21,16 +29,20 @@ jobs: fail-fast: false steps: - uses: actions/checkout@v4 + - name: Install dependencies run: bash ./tools/prepare-ci.sh + - name: Build Libs for ${{ matrix.target }} run: bash ./build.sh -e -t ${{ matrix.target }} + - name: Upload build if: failure() uses: actions/upload-artifact@v4 with: name: build-${{ matrix.target }} path: build + - name: Upload archive uses: actions/upload-artifact@v4 with: @@ -48,17 +60,20 @@ jobs: path: dist pattern: artifacts-* merge-multiple: true + - shell: bash run: | mkdir -p out find dist -name 'arduino-esp32-libs-esp*.tar.gz' -exec tar zxvf {} -C out \; cd out/tools/esp32-arduino-libs && tar zcf ../../../dist/esp32-arduino-libs.tar.gz * && cd ../../.. cp out/package_esp32_index.template.json dist/package_esp32_index.template.json + - name: Upload full esp32-arduino-libs archive uses: actions/upload-artifact@v4 with: name: esp32-arduino-libs path: dist/esp32-arduino-libs.tar.gz + - name: Upload package_esp32_index.template.json uses: actions/upload-artifact@v4 with: diff --git a/tools/docker/Dockerfile b/tools/docker/Dockerfile index a46733a34..3262cbb2d 100644 --- a/tools/docker/Dockerfile +++ b/tools/docker/Dockerfile @@ -34,7 +34,6 @@ RUN : \ python3-setuptools \ python3-venv \ wget \ - && pip3 install --upgrade pip textual-dev \ && apt-get autoremove -y \ && rm -rf /var/lib/apt/lists/* \ && : @@ -70,7 +69,8 @@ RUN echo LIBBUILDER_CHECKOUT_REF=$LIBBUILDER_CHECKOUT_REF LIBBUILDER_CLONE_BRANC fi && \ git checkout $LIBBUILDER_CHECKOUT_REF && \ git submodule update --init --recursive; \ - fi + fi && \ + pip3 install --upgrade -r $LIBBUILDER_PATH/tools/config_editor/requirements.txt COPY entrypoint.sh $LIBBUILDER_PATH/entrypoint.sh