Skip to content

Merge pull request #142 from dtcarls/develop #27

Merge pull request #142 from dtcarls/develop

Merge pull request #142 from dtcarls/develop #27

name: Publish image on commit or published release
on:
push:
branches:
- master
- main
release:
types:
- published
jobs:
push-image:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ github.token }}
- name: Set tag name for releases
if: ${{ github.event_name == 'release' }}
run: echo "TAG=ghcr.io/${GITHUB_REPOSITORY,,}:${GITHUB_REF##*/}" >>${GITHUB_ENV}
- name: Set tag name for commits
if: ${{ github.event_name == 'push' }}
run: echo "TAG=ghcr.io/${GITHUB_REPOSITORY,,}:${{ github.sha }}" >>${GITHUB_ENV}
- name: Build image
uses: docker/build-push-action@v2
with:
load: true
push: false
tags: ${{ env.TAG }}
- name: Test image
run: |
docker run ${{ env.TAG }} /bin/sh -c "\
python -m pip install --upgrade pip && \
pip install -r requirements.txt && \
pip install -r requirements-test.txt && \
pytest"
- name: Push image to registry
uses: docker/build-push-action@v2
with:
push: true
tags: ${{ env.TAG }}