harvest: fix docker image #262
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 Images | |
on: | |
push: | |
branches: [master] | |
pull_request_target: | |
branches: [master] | |
env: | |
REGISTRY: registry.cern.ch | |
IMAGE_UI: cern-sis/cat-ui | |
IMAGE_BACKEND: cern-sis/cat-backend | |
IMAGE_HARVEST: cern-sis/cat-harvest | |
jobs: | |
backend_build_test: | |
name: Backend Build and Test | |
runs-on: ubuntu-latest | |
outputs: | |
image_backend: ${{ steps.build.outputs.image-digest }} | |
defaults: | |
run: | |
working-directory: backend | |
strategy: | |
matrix: | |
python-version: [3.9] | |
services: | |
elasticsearch: | |
image: elasticsearch:7.10.1 | |
env: | |
bootstrap.memory_lock: true | |
ES_JAVA_OPTS: -Xms1024m -Xmx1024m | |
discovery.type: single-node | |
ports: | |
- 9200:9200 | |
postgresql: | |
image: postgres:9.6 | |
env: | |
POSTGRES_USER: cat | |
POSTGRES_PASSWORD: cat | |
POSTGRES_DB: cat | |
ports: | |
- 5432:5432 | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Build Image | |
id: build | |
uses: cern-sis/gh-workflows/.github/actions/docker-build@v6 | |
with: | |
registry: ${{ env.REGISTRY }} | |
image: ${{ env.IMAGE_BACKEND }} | |
cache: false | |
context: ./backend/ | |
username: ${{ secrets.HARBOR_USERNAME }} | |
password: ${{ secrets.HARBOR_PASSWORD }} | |
- name: Run tests | |
run: > | |
docker run | |
--network=host | |
--name=cat-backend | |
$REGISTRY/$IMAGE_BACKEND@${{ steps.build.outputs.image-digest }} | |
python manage.py test | |
ui_build_test: | |
name: UI Build and Test | |
runs-on: ubuntu-latest | |
outputs: | |
image_ui: ${{ steps.build.outputs.image-digest }} | |
defaults: | |
run: | |
working-directory: ui | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- name: Build Image | |
id: build | |
uses: cern-sis/gh-workflows/.github/actions/docker-build@v6 | |
with: | |
registry: ${{ env.REGISTRY }} | |
image: ${{ env.IMAGE_UI }} | |
cache: false | |
context: ./ui/ | |
username: ${{ secrets.HARBOR_USERNAME }} | |
password: ${{ secrets.HARBOR_PASSWORD }} | |
harvest_build_test: | |
name: Harvest Build and Test | |
runs-on: ubuntu-latest | |
outputs: | |
image_harvest: ${{ steps.build.outputs.image-digest }} | |
defaults: | |
run: | |
working-directory: harvest | |
strategy: | |
matrix: | |
python-version: [3.9] | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Build Image | |
id: build | |
uses: cern-sis/gh-workflows/.github/actions/docker-build@v6 | |
with: | |
registry: ${{ env.REGISTRY }} | |
image: ${{ env.IMAGE_HARVEST }} | |
cache: false | |
context: ./harvest/ | |
username: ${{ secrets.HARBOR_USERNAME }} | |
password: ${{ secrets.HARBOR_PASSWORD }} | |
- name: Run tests | |
run: > | |
docker run | |
--network=host | |
--name=cat-harvest | |
--entrypoint poetry | |
$REGISTRY/$IMAGE_HARVEST@${{ steps.build.outputs.image-digest }} | |
run pytest tests | |
push_to_QA: | |
name: Push to QA | |
if: github.event_name == 'push' && github.ref == 'refs/heads/master' | |
runs-on: ubuntu-latest | |
needs: [backend_build_test, ui_build_test, harvest_build_test] | |
steps: | |
- name: send event | |
uses: cern-sis/gh-workflows/.github/actions/kubernetes-project-new-images@v6 | |
with: | |
event-type: update | |
images: | | |
$REGISTRY/$IMAGE_BACKEND:${{needs.backend_build_test.outputs.image_backend}} | |
$REGISTRY/$IMAGE_UI:${{needs.ui_build_test.outputs.image_ui}} | |
$REGISTRY/$IMAGE_HARVEST:${{needs.harvest_build_test.outputs.image_harvest}} | |
token: ${{ secrets.PAT_FIRE_EVENTS_ON_CERN_SIS_KUBERNETES }} |