Skip to content

Tests

Tests #663

Workflow file for this run

name: Build
on: push
jobs:
build:
runs-on: ubuntu-latest
name: Build
steps:
- name: Clone repository
uses: actions/checkout@v4
- name: Build image
run: |
docker build . \
--no-cache \
--file docker/Dockerfile \
--tag search-api
- name: Scan image
uses: aquasecurity/trivy-action@0.29.0
with:
image-ref: 'search-api'
severity: 'CRITICAL,HIGH'
format: 'sarif'
output: 'trivy.sarif'
- name: Upload scan results to GitHub Security tab
uses: github/codeql-action/upload-sarif@v3
if: always()
with:
sarif_file: 'trivy.sarif'
- name: Log in to the Container registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Push image for development
run: |
IMAGE_ID=$(echo "ghcr.io/${{ github.repository }}" | tr '[A-Z]' '[a-z]')
GIT_SHORT_HASH=$(git rev-parse --short "$GITHUB_SHA")
DATE=$(date "+%Y%m%d%H%M%S")
VERSION="dev.$DATE.$GIT_SHORT_HASH.${{ github.run_number }}"
echo "VERSION=$VERSION"
docker tag search-api $IMAGE_ID:$VERSION
docker push $IMAGE_ID:$VERSION
- name: Push image for production
if: startsWith(github.event.ref, 'refs/tags/')
run: |
IMAGE_ID=$(echo "ghcr.io/${{ github.repository }}" | tr '[A-Z]' '[a-z]')
docker tag search-api $IMAGE_ID:${GITHUB_REF_NAME#v}
docker push $IMAGE_ID:${GITHUB_REF_NAME#v}
docker tag search-api $IMAGE_ID:latest
docker push $IMAGE_ID:latest