You've already forked Promocode-API
mirror of
https://github.com/devitq/Promocode-API.git
synced 2026-05-22 20:57:11 +00:00
80 lines
2.2 KiB
YAML
80 lines
2.2 KiB
YAML
name: Run tests
|
|
|
|
on: deployment
|
|
|
|
permissions:
|
|
contents: read
|
|
packages: write
|
|
attestations: write
|
|
id-token: write
|
|
|
|
|
|
jobs:
|
|
build:
|
|
name: Build image
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 10
|
|
if: github.action != 'github-classroom[bot]'
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Log in to GitHub Container Registry
|
|
uses: docker/login-action@v2
|
|
with:
|
|
registry: ghcr.io
|
|
username: ${{ github.actor }}
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v2
|
|
|
|
- name: Save image name (lowercased)
|
|
run: echo "IMAGE_NAME=$(echo 'ghcr.io/${{ github.repository }}:run-${{ github.run_id }}' | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV
|
|
|
|
- name: Build and push image
|
|
uses: docker/build-push-action@v4
|
|
with:
|
|
context: ./solution
|
|
file: ./solution/Dockerfile
|
|
tags: ${{ env.IMAGE_NAME }}
|
|
push: true
|
|
|
|
tests:
|
|
needs: build
|
|
name: Run tests
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 20
|
|
if: github.action != 'github-classroom[bot]'
|
|
steps:
|
|
- name: Setup checker environment
|
|
uses: Central-University-IT/setup-test-2025-backend@v1
|
|
|
|
- name: Log in to GitHub Container Registry
|
|
uses: docker/login-action@v2
|
|
with:
|
|
registry: ghcr.io
|
|
username: ${{ github.actor }}
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Run tests
|
|
run: |
|
|
export IMAGE_SOLUTION=$(echo 'ghcr.io/${{ github.repository }}:run-${{ github.run_id }}' | tr '[:upper:]' '[:lower:]')
|
|
export IMAGE_ANTIFRAUD=docker.io/lodthe/prod-backend-antifraud
|
|
/usr/local/bin/checker
|
|
continue-on-error: true
|
|
|
|
- uses: actions/upload-artifact@v4.0.0
|
|
with:
|
|
name: result
|
|
path: ./result.json
|
|
if-no-files-found: error
|
|
compression-level: 0
|
|
|
|
- uses: bots-house/ghcr-delete-image-action@v1.1.0
|
|
continue-on-error: true
|
|
with:
|
|
owner: ${{ github.repository_owner }}
|
|
name: ${{ github.event.repository.name }}
|
|
token: ${{ secrets.GITHUB_TOKEN }}
|
|
tag: run-${{ github.run_id }}
|