build and push docker image #296
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: CI | |
| on: | |
| push: | |
| jobs: | |
| run_checks: | |
| name: "Run Checks (Python ${{ matrix.python }})" | |
| timeout-minutes: 10 | |
| runs-on: "ubuntu-latest" | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| python: ["3.11", "3.12", "3.13", "3.14"] | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v2 | |
| - name: Setup python | |
| uses: actions/setup-python@v2 | |
| with: | |
| python-version: "${{ matrix.python }}" | |
| - name: Install pipenv | |
| run: make get-pipenv | |
| - name: Install dependencies | |
| run: make install-deps | |
| - name: Run checks | |
| run: make check | |
| upload_to_pypi: | |
| name: "Upload To PyPI" | |
| needs: run_checks | |
| runs-on: "ubuntu-latest" | |
| if: ${{ startsWith(github.ref, 'refs/tags/v') }} | |
| steps: | |
| - uses: actions/checkout@v2 | |
| - name: Setup python | |
| uses: actions/setup-python@v2 | |
| with: | |
| python-version: "3.11" | |
| - name: Install pipenv | |
| run: make get-pipenv | |
| - name: Install dependencies | |
| run: make install-deps | |
| - name: Publish to PyPI | |
| run: make upload-to-pypi | |
| env: | |
| PYPI_API_TOKEN: ${{ secrets.PYPI_API_TOKEN }} | |
| push_to_docker_hub: | |
| name: "Push To Docker Hub" | |
| needs: run_checks | |
| runs-on: "ubuntu-latest" | |
| if: ${{ startsWith(github.ref, 'refs/tags/v') }} | |
| steps: | |
| - uses: actions/checkout@v2 | |
| - name: Set Up Docker Buildx | |
| id: buildx | |
| uses: docker/setup-buildx-action@v1 | |
| - name: Build the image | |
| run: make docker-image | |
| - name: Login To DockerHub | |
| uses: docker/login-action@v1 | |
| with: | |
| username: ${{ secrets.DOCKERHUB_USERNAME }} | |
| password: ${{ secrets.DOCKERHUB_TOKEN }} | |
| - name: Docker Meta | |
| id: docker_meta | |
| uses: docker/metadata-action@v3 | |
| with: | |
| images: enapter/python-sdk | |
| tags: | | |
| type=raw,value=${{ github.ref_name }} | |
| - name: Build And Push To DockerHub | |
| uses: docker/build-push-action@v2 | |
| with: | |
| context: . | |
| push: true | |
| tags: ${{ steps.docker_meta.outputs.tags }} | |
| labels: ${{ steps.docker_meta.outputs.labels }} | |
| push_to_enapter_docker_hub: | |
| name: "Push To Enapter Docker Hub" | |
| needs: run_checks | |
| runs-on: "ubuntu-latest" | |
| if: ${{ startsWith(github.ref, 'refs/tags/v') }} | |
| steps: | |
| - uses: actions/checkout@v2 | |
| - name: Set Up Docker Buildx | |
| id: buildx | |
| uses: docker/setup-buildx-action@v1 | |
| - name: Build The Image | |
| run: make docker-image | |
| - name: Login To DockerHub | |
| uses: docker/login-action@v1 | |
| with: | |
| registry: docker.enapter.com | |
| username: ${{ secrets.ENAPTER_DOCKERHUB_USERNAME }} | |
| password: ${{ secrets.ENAPTER_DOCKERHUB_TOKEN }} | |
| - name: Docker Meta | |
| id: enapter_docker_meta | |
| uses: docker/metadata-action@v3 | |
| with: | |
| images: docker.enapter.com/python/sdk | |
| tags: | | |
| type=raw,value=${{ github.ref_name }} | |
| - name: Build And Push To DockerHub | |
| uses: docker/build-push-action@v2 | |
| with: | |
| context: . | |
| push: true | |
| tags: ${{ steps.enapter_docker_meta.outputs.tags }} | |
| labels: ${{ steps.enapter_docker_meta.outputs.labels }} |