Skip to content

Delegate array of unique to misc function #183

Delegate array of unique to misc function

Delegate array of unique to misc function #183

name: Test && Build && Push
on:
pull_request:
branches: [main]
paths:
- sci-log-db/**
- .github/workflows/test-build-push.be.yaml
push:
branches: [main]
paths:
- sci-log-db/**
- .github/workflows/test-build-push.be.yaml
release:
types: [published]
paths:
- sci-log-db/**
- .github/workflows/test-build-push.be.yaml
env:
CONTAINER_REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}/be
CONTEXT: sci-log-db
jobs:
test:
name: Test and build image on PR
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Test
if: github.event_name != 'push'
run: |
cd $CONTEXT
docker-compose -f docker-compose.test.yaml up --build --no-deps --abort-on-container-exit --exit-code-from scilog
docker-compose -f docker-compose.test.yaml down
- name: Login to GHCR
uses: docker/login-action@v2
if: github.event_name != 'pull_request'
with:
registry: ${{ env.CONTAINER_REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract tags
id: tags
run: |
prefix=$CONTAINER_REGISTRY/$IMAGE_NAME
tags=$prefix:"${{ github.sha }}"
if [[ "${{ github.event_name }}" == "release" ]]; then
tags=$prefix:"${{ github.event.release.tag_name }}",$prefix:stable
fi
echo "tags=$tags,$prefix:latest" >> $GITHUB_OUTPUT
- name: Build
uses: docker/build-push-action@v3
with:
context: ${{ env.CONTEXT }}/.
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.tags.outputs.tags }}