From 5e2cb770b8c293ba65687be3baadd2dd1b5e9236 Mon Sep 17 00:00:00 2001 From: IlyaMuravjov Date: Sat, 25 May 2024 22:49:11 +0300 Subject: [PATCH] Add Deploy to DockerHub workflow --- .github/workflows/dockerhub-deploy.yml | 61 ++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 .github/workflows/dockerhub-deploy.yml diff --git a/.github/workflows/dockerhub-deploy.yml b/.github/workflows/dockerhub-deploy.yml new file mode 100644 index 0000000..88bbc1c --- /dev/null +++ b/.github/workflows/dockerhub-deploy.yml @@ -0,0 +1,61 @@ +name: Deploy to DockerHub + +on: + workflow_dispatch: + inputs: + docker_username: + description: 'DockerHub Username' + required: true + type: string + + # TODO ask admins to configure GitHub Secrets + docker_password: + description: 'DockerHub Password' + required: true + type: string + + image_tag: + description: 'Docker Image Tag' + required: true + type: string + +jobs: + dockerhub-deploy: + runs-on: ubuntu-latest + strategy: + matrix: + platform: [linux/amd64, linux/arm64] + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + + - name: Build Docker image + run: | + docker buildx build --load \ + --platform ${{ matrix.platform }} \ + -t cfpq/py_algo:tmp \ + . + + - name: Run tests + run: | + docker run --rm \ + cfpq/py_algo:tmp -c " + echo 'System Info:'; + uname -a; + pytest test -v -m 'CI'" + + - name: Login to DockerHub + uses: docker/login-action@v1 + with: + username: ${{ github.event.inputs.docker_username }} + password: ${{ github.event.inputs.docker_password }} + + - name: Push Docker image + run: | + docker buildx build --push \ + --platform ${{ matrix.platform }} \ + -t cfpq/py_algo:${{ github.event.inputs.image_tag }} \ + .