From 6330858f8da5041ec836b0ffdfccbe242cd76a81 Mon Sep 17 00:00:00 2001 From: Guillermo Perez Date: Tue, 21 Nov 2023 13:12:26 +0100 Subject: [PATCH] CI release bug fixes (#1611) * Fix main branch detection for docker build * Try out GHA for Pages deployment * Docker build clean up workflow * publish docker in all non-PR events * fix docs cache (github token) * Deploy docs only from main branch * revert docker build machine size --- .github/workflows/build-docker.yml | 12 +++------- .github/workflows/build-wasm.yml | 2 +- .github/workflows/docs.yml | 38 ++++++++++++++++++------------ 3 files changed, 27 insertions(+), 25 deletions(-) diff --git a/.github/workflows/build-docker.yml b/.github/workflows/build-docker.yml index f3b9181bbd..a25662f6a1 100644 --- a/.github/workflows/build-docker.yml +++ b/.github/workflows/build-docker.yml @@ -10,7 +10,7 @@ on: - ".github/workflows/build-docker.yml" - "docker/centrifuge-chain/Dockerfile" concurrency: - group: ${{ github.workflow }}-${{ github.event.pull_request.head.label || github.head_ref || github.ref }}${{ github.ref == '/refs/heads/main' && github.sha || 'false' }} + group: ${{ github.workflow }}-${{ github.event.pull_request.head.label || github.head_ref || github.ref }}${{ github.event_name }} cancel-in-progress: true jobs: docker: @@ -34,12 +34,6 @@ jobs: docker volume ls df -h - - name: Install toolchain from rust-toolchain.toml - shell: sh - run: | - TOOLCHAIN_VERSION=$(grep 'channel =' rust-toolchain.toml | awk -F'"' '{print $2}') - rustup toolchain install "$TOOLCHAIN_VERSION" - - name: Set up Docker Buildx uses: docker/setup-buildx-action@f95db51fddba0c2d1ec667646a06c2ce06100226 #v3 - name: DockerHub Login @@ -64,7 +58,7 @@ jobs: type=semver,pattern={{major}},prefix=${{ matrix.target == 'test' && 'test-' || '' }},suffix= type=edge - - name: Configure sccache + - name: Configure GHA cache uses: actions/github-script@d7906e4ad0b1822421a7e6a35d5ca353c962f410 #v6 with: script: | @@ -78,7 +72,7 @@ jobs: file: ./docker/centrifuge-chain/Dockerfile build-args: | FEATURES=${{ matrix.target == 'test' && 'fast-runtime' || '' }} - push: ${{ github.ref == '/refs/heads/main' && true || false }} + push: ${{ github.event_name == 'pull_request' && false || true }} tags: ${{ steps.meta.outputs.tags }} # Cache options: # https://docs.docker.com/build/ci/github-actions/cache/ diff --git a/.github/workflows/build-wasm.yml b/.github/workflows/build-wasm.yml index 1e0bee53a1..591fb5cbb7 100644 --- a/.github/workflows/build-wasm.yml +++ b/.github/workflows/build-wasm.yml @@ -33,7 +33,7 @@ jobs: uses: ./.github/actions/prep-ubuntu # sccache does not work inside the srtool container - - uses: Swatinem/rust-cache@e207df5d269b42b69c8bc5101da26f7d31feddb4 # 2.6.2 + - uses: Swatinem/rust-cache@3cf7f8cc28d1b4e7d01e3783be10a97d55d483c8 # 2.7 with: prefix-key: build shared-key: wasm diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 24c3972a43..1f393c59c6 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -7,14 +7,11 @@ concurrency: group: ${{ github.workflow }}-${{ github.event.pull_request.head.label || github.head_ref || github.ref }} cancel-in-progress: true jobs: - docs: + build-docs: permissions: - contents: write + contents: read id-token: write runs-on: ubuntu-latest-4-cores - env: - RUSTDOCFLAGS: "-D warnings" - RUSTC_WRAPPER: "sccache" steps: - name: Checkout repository uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac #v4 @@ -22,7 +19,6 @@ jobs: - name: Prep build on Ubuntu uses: ./.github/actions/prep-ubuntu with: - RUST_TOOLCHAIN: ${{ env.RUST_TOOLCHAIN }} cache: enabled # Cache needs Google credentials: GWIP: ${{ secrets.GWIP_SCCACHE }} @@ -31,7 +27,9 @@ jobs: - name: Build documentation id: build_docs run: cargo doc --all --no-deps - + env: + RUSTDOCFLAGS: "-D warnings" + RUSTC_WRAPPER: "sccache" - name: Build Documentation failed if: always() && steps.build_docs.outcome == 'failure' @@ -43,12 +41,22 @@ jobs: run: | echo "" \ > ./target/doc/index.html - - name: Deploy Docs - uses: peaceiris/actions-gh-pages@373f7f263a76c20808c831209c920827a82a2847 # 3.9.3 - if: github.ref == 'refs/heads/main' + - name: upload Docs files + uses: actions/upload-pages-artifact@v2 with: - github_token: ${{ secrets.GITHUB_TOKEN }} - publish_branch: gh-pages - publish_dir: ./target/doc - cname: reference.centrifuge.io - force_orphan: true + path: ./target/doc + + deploy-docs: + if: github.ref == 'refs/heads/main' + runs-on: ubuntu-latest + permissions: + pages: write # to deploy to Pages + id-token: write + # Deploy to the github-pages environment + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + steps: + - name: Deploy Docs + id: deployment + uses: actions/deploy-pages@v2 \ No newline at end of file