From 6fe71907f8352fc54c3cb3e8130fa5b7d6490b93 Mon Sep 17 00:00:00 2001 From: Iain Emsley Date: Tue, 29 Jul 2025 09:27:16 +0100 Subject: [PATCH 1/6] amd64 workflow --- .github/workflows/call_jobs.yml | 22 ++++ .github/workflows/reuse-build-publish-amd.yml | 102 ++++++++++++++++++ 2 files changed, 124 insertions(+) create mode 100644 .github/workflows/call_jobs.yml create mode 100644 .github/workflows/reuse-build-publish-amd.yml diff --git a/.github/workflows/call_jobs.yml b/.github/workflows/call_jobs.yml new file mode 100644 index 000000000..36951d493 --- /dev/null +++ b/.github/workflows/call_jobs.yml @@ -0,0 +1,22 @@ +name: Call reusable workflows + +on: + push: + branches: + - master + - devel + +jobs: + call-workflow-amd64: + permissions: + contents: read + packages: write + uses: r-devel/r-dev-env/.github/workflows/reuse-build-and-publish.yml@devel + with: + event_name: ${{ github.event_name }} + pull_request: ${{ github.pull_request.merged }} + image_name: ${{ github.repository }} + ref_name: ${{ github.ref_name }} + actor: ${{ github.actor }} + registry: ghcr.io + secrets: inherit \ No newline at end of file diff --git a/.github/workflows/reuse-build-publish-amd.yml b/.github/workflows/reuse-build-publish-amd.yml new file mode 100644 index 000000000..013ac5a76 --- /dev/null +++ b/.github/workflows/reuse-build-publish-amd.yml @@ -0,0 +1,102 @@ +# This workflow uses actions that are not certified by GitHub. +# They are provided by a third-party and are governed by +# separate terms of service, privacy policy, and support +# documentation. + +name: Build and publish amd 64 Docker image + +on: + workflow_call: + inputs: + event_name: + description: event name + required: true + type: string + pull_request: + description: pull request + required: false + type: string + image_name: + description: image name + required: true + type: string + ref_name: + description: ref name + required: true + type: string + actor: + description: actor + required: true + type: string + registry: + description: registry + required: true + type: string + push: + branches: + - main + - devel + paths: + - '.github/workflows/reuse-build-and-publish.yml' + pull_request: + branches: + - main + - devel + types: + - closed + paths: + - '.github/workflows/reuse-build-and-publish.yml' + - '.devcontainer/devcontainer.json' + - 'Dockerfile' + - 'reinstall-cmake.sh' + - 'VERSION' + +permissions: + contents: read + packages: write + +jobs: + reuse-build-and-push: + if: | + ${{ inputs.event_name }} == 'workflow_dispatch' || + ${{ inputs.event_name }} == 'push' || + (${{ inputs.event_name }} == 'pull_request' && + ${{ inputs.pull_request }} == true) + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Extract version number + run: | + VER=$(cat VERSION) + echo "VERSION=$VER" >> $GITHUB_ENV + + - name: Log in to the Container registry + uses: docker/login-action@v3 + with: + registry: ${{ inputs.registry }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ inputs.registry }}/${{ inputs.image_name }} + tags: | + type=ref,event=branch + type=ref,event=pr + type=semver,pattern=${{ env.VERSION }} + type=sha + + - name: Build and push Docker image + uses: docker/build-push-action@v5 + with: + context: . + push: true + tags: ${{ inputs.registry }}/${{ inputs.image_name }}:${{ inputs.ref_name }} + build-args: | + CONTAINER_VERSION=${{ env.VERSION }} + labels: ${{ steps.meta.outputs.labels }} \ No newline at end of file From 1fa3eb0cd33896b9c35e00b92525cfa8d88c91fa Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 29 Jul 2025 08:34:03 +0000 Subject: [PATCH 2/6] [pre-commit.ci] Fixing issues with pre-commit --- .github/workflows/call_jobs.yml | 2 +- .github/workflows/reuse-build-publish-amd.yml | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/call_jobs.yml b/.github/workflows/call_jobs.yml index 36951d493..f55095bb3 100644 --- a/.github/workflows/call_jobs.yml +++ b/.github/workflows/call_jobs.yml @@ -19,4 +19,4 @@ jobs: ref_name: ${{ github.ref_name }} actor: ${{ github.actor }} registry: ghcr.io - secrets: inherit \ No newline at end of file + secrets: inherit diff --git a/.github/workflows/reuse-build-publish-amd.yml b/.github/workflows/reuse-build-publish-amd.yml index 013ac5a76..0ffe91de8 100644 --- a/.github/workflows/reuse-build-publish-amd.yml +++ b/.github/workflows/reuse-build-publish-amd.yml @@ -8,27 +8,27 @@ name: Build and publish amd 64 Docker image on: workflow_call: inputs: - event_name: + event_name: description: event name required: true type: string - pull_request: + pull_request: description: pull request required: false type: string - image_name: + image_name: description: image name required: true type: string - ref_name: + ref_name: description: ref name required: true type: string - actor: + actor: description: actor required: true type: string - registry: + registry: description: registry required: true type: string @@ -99,4 +99,4 @@ jobs: tags: ${{ inputs.registry }}/${{ inputs.image_name }}:${{ inputs.ref_name }} build-args: | CONTAINER_VERSION=${{ env.VERSION }} - labels: ${{ steps.meta.outputs.labels }} \ No newline at end of file + labels: ${{ steps.meta.outputs.labels }} From 9aa71e07dcb8484e9451d7c3acc0d48d00943cf1 Mon Sep 17 00:00:00 2001 From: Iain Emsley Date: Tue, 29 Jul 2025 14:36:33 +0100 Subject: [PATCH 3/6] Updated inputs --- .github/workflows/reuse-build-publish-amd.yml | 34 ++----------------- 1 file changed, 2 insertions(+), 32 deletions(-) diff --git a/.github/workflows/reuse-build-publish-amd.yml b/.github/workflows/reuse-build-publish-amd.yml index 013ac5a76..fdb711fb6 100644 --- a/.github/workflows/reuse-build-publish-amd.yml +++ b/.github/workflows/reuse-build-publish-amd.yml @@ -8,14 +8,6 @@ name: Build and publish amd 64 Docker image on: workflow_call: inputs: - event_name: - description: event name - required: true - type: string - pull_request: - description: pull request - required: false - type: string image_name: description: image name required: true @@ -32,36 +24,13 @@ on: description: registry required: true type: string - push: - branches: - - main - - devel - paths: - - '.github/workflows/reuse-build-and-publish.yml' - pull_request: - branches: - - main - - devel - types: - - closed - paths: - - '.github/workflows/reuse-build-and-publish.yml' - - '.devcontainer/devcontainer.json' - - 'Dockerfile' - - 'reinstall-cmake.sh' - - 'VERSION' - permissions: contents: read packages: write jobs: reuse-build-and-push: - if: | - ${{ inputs.event_name }} == 'workflow_dispatch' || - ${{ inputs.event_name }} == 'push' || - (${{ inputs.event_name }} == 'pull_request' && - ${{ inputs.pull_request }} == true) + runs-on: ubuntu-latest steps: @@ -96,6 +65,7 @@ jobs: with: context: . push: true + pull: true tags: ${{ inputs.registry }}/${{ inputs.image_name }}:${{ inputs.ref_name }} build-args: | CONTAINER_VERSION=${{ env.VERSION }} From be085f123c91afb636633dd6a19cb0e69259f8c2 Mon Sep 17 00:00:00 2001 From: Iain Emsley Date: Tue, 29 Jul 2025 14:39:35 +0100 Subject: [PATCH 4/6] Moved pull request here and branching to call workflow on branches as uses must be hard-coded --- .github/workflows/call_jobs.yml | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/.github/workflows/call_jobs.yml b/.github/workflows/call_jobs.yml index 36951d493..9ef8856a7 100644 --- a/.github/workflows/call_jobs.yml +++ b/.github/workflows/call_jobs.yml @@ -1,20 +1,36 @@ name: Call reusable workflows on: - push: + pull_request: branches: - - master + - main - devel + types: + - closed + paths: + - '.github/workflows/reuse-build-and-publish-amd.yml' + - '.devcontainer/devcontainer.json' + - 'Dockerfile' + - 'reinstall-cmake.sh' + - 'VERSION' jobs: - call-workflow-amd64: + call-workflow-amd64-main: + if: ${{ github.ref_name == 'main' }} permissions: contents: read packages: write + uses: r-devel/r-dev-env/.github/workflows/reuse-build-and-publish.yml@main + with: + image_name: ${{ github.repository }} + ref_name: ${{ github.ref_name }} + actor: ${{ github.actor }} + registry: ghcr.io + secrets: inherit + call-workflow-amd64-devel: + if: ${{ github.ref_name == 'devel' }} uses: r-devel/r-dev-env/.github/workflows/reuse-build-and-publish.yml@devel with: - event_name: ${{ github.event_name }} - pull_request: ${{ github.pull_request.merged }} image_name: ${{ github.repository }} ref_name: ${{ github.ref_name }} actor: ${{ github.actor }} From 7d2055bb286f8e911896b48e0f466b81f11fa6d8 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 29 Jul 2025 13:43:12 +0000 Subject: [PATCH 5/6] [pre-commit.ci] Fixing issues with pre-commit --- .github/workflows/reuse-build-publish-amd.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/reuse-build-publish-amd.yml b/.github/workflows/reuse-build-publish-amd.yml index 061c93d88..ccaec559c 100644 --- a/.github/workflows/reuse-build-publish-amd.yml +++ b/.github/workflows/reuse-build-publish-amd.yml @@ -8,7 +8,7 @@ name: Build and publish amd 64 Docker image on: workflow_call: inputs: - image_name: + image_name: description: image name required: true type: string From 63d1f20a47236104ff8f05df6c62d71675ed3f6c Mon Sep 17 00:00:00 2001 From: Iain Emsley Date: Tue, 29 Jul 2025 15:01:19 +0100 Subject: [PATCH 6/6] Refactor to use local paths and remove variables --- .github/workflows/call_jobs.yml | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/.github/workflows/call_jobs.yml b/.github/workflows/call_jobs.yml index 40f162c7d..ee6410366 100644 --- a/.github/workflows/call_jobs.yml +++ b/.github/workflows/call_jobs.yml @@ -15,21 +15,11 @@ on: - 'VERSION' jobs: - call-workflow-amd64-main: - if: ${{ github.ref_name == 'main' }} + call-workflow-amd64: permissions: contents: read packages: write - uses: r-devel/r-dev-env/.github/workflows/reuse-build-and-publish.yml@main - with: - image_name: ${{ github.repository }} - ref_name: ${{ github.ref_name }} - actor: ${{ github.actor }} - registry: ghcr.io - secrets: inherit - call-workflow-amd64-devel: - if: ${{ github.ref_name == 'devel' }} - uses: r-devel/r-dev-env/.github/workflows/reuse-build-and-publish.yml@devel + uses: ./.github/workflows/reuse-build-and-publish.yml with: image_name: ${{ github.repository }} ref_name: ${{ github.ref_name }}