From 5bf1c3ee9a3ca128bb35f563b7e76d6b9445e650 Mon Sep 17 00:00:00 2001 From: Kate Isaac <41767733+kweav@users.noreply.github.com> Date: Tue, 3 Dec 2024 17:56:33 -0500 Subject: [PATCH] borrow from ottr-docker --- .github/workflows/docker-test.yml | 59 +++++++++++++++++++++++++++ .github/workflows/manual_dispatch.yml | 35 ++++++++++++++++ 2 files changed, 94 insertions(+) create mode 100644 .github/workflows/docker-test.yml create mode 100644 .github/workflows/manual_dispatch.yml diff --git a/.github/workflows/docker-test.yml b/.github/workflows/docker-test.yml new file mode 100644 index 0000000..c4c80e4 --- /dev/null +++ b/.github/workflows/docker-test.yml @@ -0,0 +1,59 @@ +# Candace Savonen Apr 2022 + +name: Build Docker Image + +on: + workflow_call: + inputs: + directory: + required: true + type: string + tag: + required: true + type: string + dockerhubpush: + description: 'Push to Dockerhub?' + required: false + default: 'false' + type: string + secrets: + GH_PAT: + required: true + DOCKERHUB_USERNAME: + required: false + DOCKERHUB_TOKEN: + required: false + +defaults: + run: + working-directory: ./ + +jobs: + + build-docker: + name: Build Docker image + runs-on: ubuntu-latest + + steps: + - name: checkout repo + uses: actions/checkout@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Login to Docker Hub + if: ${{ inputs.dockerhubpush != 'false' }} + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Build + uses: docker/build-push-action@v6 + with: + push: ${{ inputs.dockerhubpush }} + context: ${{ inputs.directory }} + file: ${{ inputs.directory }}/Dockerfile + platforms: linux/amd64 + tags: ${{ inputs.tag }} + diff --git a/.github/workflows/manual_dispatch.yml b/.github/workflows/manual_dispatch.yml new file mode 100644 index 0000000..cc671bc --- /dev/null +++ b/.github/workflows/manual_dispatch.yml @@ -0,0 +1,35 @@ +# Candace Savonen May 2022 + +name: Manual build of docker image + +on: + workflow_dispatch: + inputs: + directory: + description: 'File path on GitHub to Dockerfile? e.g. inst/extdata' + required: true + default: inst/extdata + type: string + tag: + description: 'Tag e.g. fhdsl/metricminer:main' + required: true + type: string + dockerhubpush: + description: 'Push to Dockerhub? true or false' + required: false + default: 'false' + type: string + +jobs: + + build-it: + name: Build docker image on command + uses: ./.github/workflows/docker-test.yml + with: + directory: ${{github.event.inputs.directory}} + tag: ${{github.event.inputs.tag}} + dockerhubpush: ${{github.event.inputs.dockerhubpush}} + secrets: + GH_PAT: ${{ secrets.GH_PAT }} + DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} + DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}