run isort, pyupgrade, mypy via pre-commit #73
Workflow file for this run
This file contains 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: Create and publish a Docker image | |
on: | |
release: | |
types: | |
- created | |
pull_request: | |
paths: | |
- kbatch-proxy/** | |
- .github/workflows/publish-image.yaml | |
push: | |
branches: | |
- main | |
paths: | |
- kbatch-proxy/** | |
- .github/workflows/publish-image.yaml | |
env: | |
REGISTRY: ghcr.io | |
IMAGE_NAME: ${{ github.repository }}-proxy | |
jobs: | |
build-and-push-image: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
packages: write | |
services: | |
# So that we can test this in PRs/branches | |
local-registry: | |
image: registry:2 | |
ports: | |
- 5000:5000 | |
steps: | |
- name: Should we push this image to a public registry? | |
if: github.event_name == 'pull_request' | |
run: | | |
echo "REGISTRY=localhost:5000" >> $GITHUB_ENV | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Set up QEMU (for docker buildx) | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx (for multi-arch builds) | |
uses: docker/setup-buildx-action@v3 | |
with: | |
# Allows pushing to registry on localhost:5000 | |
driver-opts: network=host | |
- name: Log in to the container registry | |
if: env.REGISTRY != 'localhost:5000' | |
uses: docker/login-action@v3 | |
with: | |
registry: ${{ env.REGISTRY }} | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Extract metadata (tags, labels) for Docker | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | |
tags: | | |
type=ref,event=tag | |
type=ref,event=branch | |
type=sha,prefix=dev-,event=branch | |
- name: Build and push Docker image | |
uses: docker/build-push-action@v5 | |
with: | |
context: kbatch-proxy | |
platforms: linux/amd64,linux/arm64 | |
file: kbatch-proxy/docker/production/Dockerfile | |
push: true | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |
build-pypi: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: "3.x" | |
- name: Install release dependencies | |
run: | | |
python -m pip install --upgrade build twine | |
- name: Build releases | |
run: | | |
python3 -m build ./kbatch-proxy | |
python3 -m build ./kbatch | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: kbatch-${{ github.sha }} | |
path: "kbatch/dist/*" | |
if-no-files-found: error | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: kbatch-proxy-${{ github.sha }} | |
path: "kbatch-proxy/dist/*" | |
if-no-files-found: error | |
- name: Publish kbatch to PyPI | |
if: startsWith(github.ref, 'refs/tags/') | |
env: | |
TWINE_USERNAME: "__token__" | |
TWINE_PASSWORD: ${{ secrets.KBATCH_PYPI_PASSWORD }} | |
run: | | |
twine upload kbatch/dist/* | |
- name: Publish kbatch-proxy to PyPI | |
if: startsWith(github.ref, 'refs/tags/') | |
env: | |
TWINE_USERNAME: "__token__" | |
TWINE_PASSWORD: ${{ secrets.KBATCH_PROXY_PYPI_PASSWORD }} | |
run: | | |
twine upload kbatch-proxy/dist/* | |