From 2d2c386f9a42daec85bbf305da522688d6c88780 Mon Sep 17 00:00:00 2001 From: Chris Markiewicz Date: Thu, 10 Oct 2024 12:14:25 -0400 Subject: [PATCH 1/8] CI: Build docker image on GHA --- .github/workflows/docker.yml | 51 ++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 .github/workflows/docker.yml diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml new file mode 100644 index 00000000..64eaa201 --- /dev/null +++ b/.github/workflows/docker.yml @@ -0,0 +1,51 @@ +name: Docker build + +on: + workflow_dispatch: + push: + branches: [ "master", "maint/*" ] + tags: "*" + pull_request: + branches: [ "master" ] + +env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }} + +jobs: + build-container: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Setup Docker buildx + uses: docker/setup-buildx-action@v2 + + - name: Log into registry ${{ env.REGISTRY }} + if: github.event_name != 'pull_request' + uses: docker/login-action@v2 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract Docker metadata + id: meta + uses: docker/metadata-action@v4 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + + - name: Build and push Docker image + id: build-and-push + uses: docker/build-push-action@v4 + with: + context: . + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + cache-from: type=registry,ref=${{ fromJSON(steps.meta.outputs.json).tags[0] }} + cache-to: inline From c28707c4b096cbcb5d370fdec327d0fc9947a2ab Mon Sep 17 00:00:00 2001 From: Chris Markiewicz Date: Thu, 10 Oct 2024 12:14:54 -0400 Subject: [PATCH 2/8] CI: Disable CircleCI globally with [skipcircle] --- .circleci/config.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.circleci/config.yml b/.circleci/config.yml index 7cf84562..bc2689be 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -47,6 +47,7 @@ _check_skip_job: &check_skip_job cd /tmp/src/fmriprep COMMIT_MSG="$(git show -s --format=%s)" DOCBUILD="$(echo ${COMMIT_MSG} | grep -i -E '^docs?(\(\w+\))?:')" + SKIP_ALL="$(echo ${COMMIT_MSG} | grep -i -E '\[skipcircle\]')" SKIP_PYTEST="$(echo ${COMMIT_MSG} | grep -i -E '\[skip[ _]?tests\]')" SKIP_DS005="$(echo ${COMMIT_MSG} | grep -i -E '\[skip[ _]?ds005\]' )" SKIP_DS054="$(echo ${COMMIT_MSG} | grep -i -E '\[skip[ _]?ds054\]' )" @@ -62,6 +63,9 @@ _check_skip_job: &check_skip_job elif [[ -n "$DOCSBUILD" ]]; then # always try to skip docs builds echo "Only docs build" circleci step halt + elif [ -n "$SKIP_ALL" ]; then + echo "Skipping all!" + circleci step halt elif [ -n "$CHECK_PYTEST" -a -n "$SKIP_PYTEST" ]; then echo "Skipping pytest" circleci step halt From 890072d1009e85de158edf247f1d0821f8c6f8e7 Mon Sep 17 00:00:00 2001 From: Chris Markiewicz Date: Thu, 10 Oct 2024 12:32:56 -0400 Subject: [PATCH 3/8] CI: Try building from base repo [skipcircle] --- .github/workflows/docker.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 64eaa201..1484fff0 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -3,7 +3,7 @@ name: Docker build on: workflow_dispatch: push: - branches: [ "master", "maint/*" ] + branches: [ "master", "maint/*", "ci/gha-docker-build" ] tags: "*" pull_request: branches: [ "master" ] From 64e01ab1468a046821045f245b16e32e6e959472 Mon Sep 17 00:00:00 2001 From: Chris Markiewicz Date: Fri, 11 Oct 2024 11:52:51 -0400 Subject: [PATCH 4/8] CI: Use GHCR for caching directly --- .github/workflows/docker.yml | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 1484fff0..454fe7d6 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -3,10 +3,10 @@ name: Docker build on: workflow_dispatch: push: - branches: [ "master", "maint/*", "ci/gha-docker-build" ] + branches: [ "master", "main", "maint/*", "ci/gha-docker-build" ] tags: "*" pull_request: - branches: [ "master" ] + branches: [ "master", "main", "maint/*" ] env: REGISTRY: ghcr.io @@ -40,12 +40,18 @@ jobs: images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} - name: Build and push Docker image - id: build-and-push uses: docker/build-push-action@v4 with: context: . push: ${{ github.event_name != 'pull_request' }} tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} - cache-from: type=registry,ref=${{ fromJSON(steps.meta.outputs.json).tags[0] }} - cache-to: inline + cache-from: | + type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:cache + type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:cache-${{ env.TARGET_BRANCH }} + type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:cache-${{ github.ref_name }} + cache-to: | + type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:cache,mode=max + type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:cache-${{ github.ref_name }},mode=max + env: + TARGET_BRANCH: ${{ github.base_ref || github.ref_name }} From 6f2f39e048b960cc7ac50851b8aa5ec33dcc14bb Mon Sep 17 00:00:00 2001 From: Chris Markiewicz Date: Fri, 11 Oct 2024 11:55:01 -0400 Subject: [PATCH 5/8] CI: Update GHA config [skipcircle] --- .github/workflows/docker.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 454fe7d6..95fb6275 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -8,9 +8,14 @@ on: pull_request: branches: [ "master", "main", "maint/*" ] +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + env: REGISTRY: ghcr.io IMAGE_NAME: ${{ github.repository }} + FORCE_COLOR: true jobs: build-container: From 2f27de86cc20abc788d18227d2ffb2e130ed0c4c Mon Sep 17 00:00:00 2001 From: Chris Markiewicz Date: Fri, 11 Oct 2024 11:56:48 -0400 Subject: [PATCH 6/8] CI: Rename branch [skipcircle] --- .github/workflows/docker.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 95fb6275..f8d86052 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -3,7 +3,7 @@ name: Docker build on: workflow_dispatch: push: - branches: [ "master", "main", "maint/*", "ci/gha-docker-build" ] + branches: [ "master", "main", "maint/*", "gha-docker-build" ] tags: "*" pull_request: branches: [ "master", "main", "maint/*" ] From 71685eb96d730a7496294ed9e76aa97fe634d688 Mon Sep 17 00:00:00 2001 From: Chris Markiewicz Date: Fri, 11 Oct 2024 13:46:38 -0400 Subject: [PATCH 7/8] Try caching inline again --- .github/workflows/docker.yml | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index f8d86052..ddfcccaa 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -52,11 +52,9 @@ jobs: tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} cache-from: | - type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:cache - type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:cache-${{ env.TARGET_BRANCH }} - type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:cache-${{ github.ref_name }} - cache-to: | - type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:cache,mode=max - type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:cache-${{ github.ref_name }},mode=max + type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:master + type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.TARGET_BRANCH }} + type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.meta.outputs.tags[0] }} + cache-to: type=inline env: TARGET_BRANCH: ${{ github.base_ref || github.ref_name }} From 79ee1b6f12a1ca98c861da2ca27d8d41f4d8f357 Mon Sep 17 00:00:00 2001 From: Chris Markiewicz Date: Fri, 11 Oct 2024 14:09:14 -0400 Subject: [PATCH 8/8] CI: Update action versions [skipcircle] --- .github/workflows/docker.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index ddfcccaa..e83bd6b9 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -25,14 +25,14 @@ jobs: packages: write steps: - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Setup Docker buildx - uses: docker/setup-buildx-action@v2 + uses: docker/setup-buildx-action@v3 - name: Log into registry ${{ env.REGISTRY }} if: github.event_name != 'pull_request' - uses: docker/login-action@v2 + uses: docker/login-action@v3 with: registry: ${{ env.REGISTRY }} username: ${{ github.actor }} @@ -40,12 +40,12 @@ jobs: - name: Extract Docker metadata id: meta - uses: docker/metadata-action@v4 + uses: docker/metadata-action@v5 with: images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} - name: Build and push Docker image - uses: docker/build-push-action@v4 + uses: docker/build-push-action@v6 with: context: . push: ${{ github.event_name != 'pull_request' }}