diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index caef55afc..89704ab14 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -2,6 +2,9 @@ name: Python package on: [push] +env: + EXAMPLE_IMAGE_NAME: ghcr.io/descope/py-example:0.1 + jobs: build: @@ -52,6 +55,21 @@ jobs: run: | python -m pytest tests/* + pkg: + runs-on: ubuntu-latest + needs: build + if: ${{ github.ref == 'refs/heads/main' }} + steps: + - uses: actions/checkout@v3 + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: 3.7 + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -r requirements-dev.txt - name: Build package run: | mkdir src @@ -61,4 +79,20 @@ jobs: uses: actions/upload-artifact@v3 with: name: descope-auth-0.0.1.tar.gz - path: ./dist/descope-auth-0.0.1.tar.gz + path: ./dist/descope-auth-0.0.1.tar.gz + + - run: cp ./dist/descope-auth-0.0.1.tar.gz samples/ + + - name: Build example docker image + working-directory: samples/ + run: | + docker build . --tag ${{ env.EXAMPLE_IMAGE_NAME }} + + - name: Log in to the Container registry + uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Push the tagged Docker image + run: docker push ${{ env.EXAMPLE_IMAGE_NAME }} diff --git a/samples/Dockerfile b/samples/Dockerfile new file mode 100644 index 000000000..3b17e6c2d --- /dev/null +++ b/samples/Dockerfile @@ -0,0 +1,15 @@ +FROM python:3 + +WORKDIR /home/app + +COPY descope-auth-0.0.1.tar.gz /home/app + +RUN pip3 install /home/app/descope-auth-0.0.1.tar.gz + +ADD requirements.txt /home/app +RUN pip3 install -r requirements.txt + +ADD . /home/app +CMD python3 otp_web_sample_app.py + +EXPOSE 3000 \ No newline at end of file diff --git a/samples/requirements.txt b/samples/requirements.txt new file mode 100644 index 000000000..0707fb201 --- /dev/null +++ b/samples/requirements.txt @@ -0,0 +1,5 @@ +requests +flask +flake8 +PyJWT +Descope-Auth