Skip to content

Merge pull request #3 from manics/dependabot-docker #27

Merge pull request #3 from manics/dependabot-docker

Merge pull request #3 from manics/dependabot-docker #27

Workflow file for this run

name: Build
on:
push:
pull_request:
jobs:
lint:
runs-on: ubuntu-22.04
timeout-minutes: 2
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
- uses: pre-commit/action@v3.0.0
build:
runs-on: ubuntu-22.04
timeout-minutes: 2
steps:
- name: Checkout repo
uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: "3.10"
cache: pip
cache-dependency-path: dev-requirements.txt
- name: Install
run: |
pip install -r dev-requirements.txt
# Make a wheel and install it to catch possible issues with releases
python -m build --wheel
pip install dist/*.whl
pip freeze
test:
runs-on: ubuntu-22.04
timeout-minutes: 10
steps:
- name: Checkout repo
uses: actions/checkout@v4
- name: Configure insecure Podman registry
run: |
REGISTRY_HOST=$(hostname -I | awk '{print $1}'):5000
echo "REGISTRY_HOST=${REGISTRY_HOST}" >> $GITHUB_ENV
mkdir -p ~/.config/containers/
cat <<EOF >> ~/.config/containers/registries.conf
[registries.insecure]
registries = [
'localhost:5000',
'${REGISTRY_HOST}',
]
EOF
- name: Run registry for testing
run: |
./ci/run-local-registry.sh &
while ! curl -f http://localhost:5000; do
sleep 5
done
- name: Podman info
run: podman info
- name: Build and test container
run: |
./ci/build-and-test.sh
# https://packaging.python.org/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/
publish-pypi:
name: Pypi
needs:
# Only publish if other jobs passed
- lint
- build
- test
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
- name: Install pypa/build
run: python -m pip install build
- name: Build a binary wheel and a source tarball
run: python -m build --sdist --wheel --outdir dist/
- name: Publish to PyPI
if: startsWith(github.ref, 'refs/tags')
uses: pypa/gh-action-pypi-publish@v1.8.10
with:
password: ${{ secrets.PYPI_API_TOKEN }}
container:
name: Build container
needs:
# Only publish if other jobs passed
- lint
- build
- test
runs-on: ubuntu-22.04
timeout-minutes: 10
permissions:
contents: read
packages: write
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get short reference (e.g. branch or tag)
# If there are multiple / (e.g. refs/prs/123/merge) use the last component
run: |
echo "SHORT_REF=${GITHUB_REF##refs*/}" >> $GITHUB_ENV
# https://www.redhat.com/en/blog/build-ubi-containers-github-actions-buildah-and-podman
- name: Buildah Action
id: build-image
uses: redhat-actions/buildah-build@v2
with:
image: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: ${{ env.SHORT_REF }}
containerfiles: |
./Dockerfile
- name: Log in to the GitHub Container registry
if: startsWith(github.ref, 'refs/tags/') || (github.ref == 'refs/heads/main')
uses: redhat-actions/podman-login@v1
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Push to GitHub Container Repository
if: startsWith(github.ref, 'refs/tags/') || (github.ref == 'refs/heads/main')
uses: redhat-actions/push-to-registry@v2
with:
image: ${{ steps.build-image.outputs.image }}
tags: ${{ steps.build-image.outputs.tags }}
registry: ${{ env.REGISTRY }}
- name: Run repo2docker image
run: |
podman run ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.SHORT_REF }} repo2docker --version