Skip to content

MiR Docker build actions #57

MiR Docker build actions

MiR Docker build actions #57

Workflow file for this run

name: MiR Connector Workflow
on:
push:
branches:
- main
paths:
- mir_connector/**
pull_request:
branches:
- main
paths:
- mir_connector/**
jobs:
lint:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
python-version: ["3.11"]
os: [ubuntu-latest]
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- name: Lint with flake8
uses: py-actions/flake8@v2
with:
path: mir_connector
max-line-length: 100
- name: Check with black
uses: psf/black@stable
with:
version: "~= 23.0"
src: mir_connector
options: "--diff --check --line-length=100"
test:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
python-version: ["3.10", "3.11", "3.12"]
os: [ubuntu-latest, windows-latest, macOS-latest]
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
cd mir_connector
python -m pip install --upgrade pip
python -m pip install -e .["test"]
- name: Test with pytest
run: |
cd mir_connector
pytest
publish-pypi:
if: contains(github.event.head_commit.message, 'Bump version')
needs: [test, lint]
runs-on: ubuntu-latest
strategy:
fail-fast: true
environment: release
permissions:
id-token: write
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: "3.11"
- name: Install Dependencies
run: |
cd mir_connector
python -m pip install --upgrade pip
python -m pip install .[dev]
- name: Build Package
run: |
cd mir_connector
python -m build --sdist
twine check dist/*
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://test.pypi.org/legacy/
packages-dir: mir_connector/dist/
docker-build:
# ${{ contains(github.event.head_commit.message, 'Bump version') }} # TODO: reenable
# needs: [test, lint] # TODO: reenable
runs-on: ubuntu-latest
strategy:
fail-fast: true
environment: release
steps:
- name: Check out the repo
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Google Artifact Registry
uses: docker/login-action@v3
with:
registry: us-central1-docker.pkg.dev
username: _json_key
password: ${{ secrets.GAR_JSON_KEY }}
- name: Build and push
uses: docker/build-push-action@v6
with:
context: mir_connector/
file: ./docker/Dockerfile
push: false
tags: us-central1-docker.pkg.dev/inorbit-integrations/connectors/mir_connector:latest # ${{ steps.meta.outputs.tags }}
# - name: Generate artifact attestation
# uses: actions/attest-build-provenance@v1
# with:
# subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}}
# subject-digest: ${{ steps.push.outputs.digest }}
# push-to-registry: true