IGU-00 nginx is not allowed in development image #37
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: Test & Build | |
on: | |
push: | |
branches: | |
- master | |
tags: | |
- "production-[0-9]+" | |
pull_request: | |
jobs: | |
test: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Read Python version | |
run: | | |
echo "PYTHON_VERSION=$(cat .python-version)" >> $GITHUB_ENV | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '${{ env.PYTHON_VERSION }}' | |
- name: Install dependencies | |
run: | | |
sudo apt-get update -y | |
sudo apt-get install -y libexempi8 | |
- name: Prepare test environment | |
run: | | |
make development | |
# requirement for coveralls.io | |
pip install coveralls | |
- name: Run all tests | |
run: make coverage +c | |
- name: Publish coverage | |
if: ${{ success() }} | |
run: | | |
pushd src | |
coveralls --service=github | |
popd | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
build: | |
needs: test | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Read Python version | |
run: | | |
PYTHON_VERSION=$(cat .python-version) | |
echo "PYTHON_VERSION=${PYTHON_VERSION%.*}" >> $GITHUB_ENV | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
with: | |
version: latest | |
- name: Login to GH Docker registry | |
uses: docker/login-action@v2 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Determine build target | |
id: build-target | |
run: | | |
case "$GITHUB_REF" in | |
refs/tags*) | |
echo "TARGET=production" >> $GITHUB_OUTPUT | |
# get the current production number | |
p_num=$(echo "$GITHUB_REF" | sed -E "s/.*production-([0-9]+)/\1/") | |
echo "PRODUCTION_NUM=$p_num" >> $GITHUB_OUTPUT | |
;; | |
*) | |
echo "TARGET=default" >> $GITHUB_OUTPUT | |
echo "PRODUCTION_NUM=" >> $GITHUB_OUTPUT | |
;; | |
esac | |
- name: Build and push | |
uses: docker/bake-action@v2 | |
with: | |
files: docker/docker-bake.hcl | |
targets: ${{ steps.build-target.outputs.TARGET }} | |
# only publish on Docker Hub if there was a push to the repository | |
push: ${{ github.event_name == 'push' }} | |
env: | |
PRODUCTION_NUM: ${{ steps.build-target.outputs.PRODUCTION_NUM }} | |
PYTHON_VERSION: ${{ env.PYTHON_VERSION }} | |
BUILDX_NO_DEFAULT_ATTESTATIONS: true |