chore: remove ads #110
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: Build Docker Images | |
on: | |
push: | |
branches: | |
- dev | |
- master | |
env: | |
REGISTRY: ghcr.io | |
IMAGE_NAME: vichannnnn/holy-grail | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Path filter | |
id: path-filter | |
uses: dorny/paths-filter@v2 | |
with: | |
filters: | | |
frontend: | |
- 'holy-grail-frontend/**' | |
backend: | |
- 'holy-grail-backend/**' | |
- name: Set up Docker Buildx | |
if: steps.path-filter.outputs.frontend == 'true' || steps.path-filter.outputs.backend == 'true' | |
uses: docker/setup-buildx-action@v1 | |
- name: Cache Docker layers | |
if: steps.path-filter.outputs.frontend == 'true' || steps.path-filter.outputs.backend == 'true' | |
uses: actions/cache@v2 | |
with: | |
path: /tmp/.buildx-cache | |
key: ${{ runner.os }}-buildx-${{ github.sha }} | |
restore-keys: | | |
${{ runner.os }}-buildx- | |
- name: Login to GitHub Container Registry | |
if: steps.path-filter.outputs.frontend == 'true' || steps.path-filter.outputs.backend == 'true' | |
uses: docker/login-action@v1 | |
with: | |
registry: ${{ env.REGISTRY }} | |
username: ${{ github.repository_owner }} | |
password: ${{ secrets.CICD_TOKEN }} | |
- name: Backend Tests | |
if: steps.path-filter.outputs.backend == 'true' | |
run: | | |
cp .env.example .env | |
make coverage version="dev" | |
make generate_xml version="dev" | |
cp ./holy-grail-backend/backend/coverage.xml ./coverage.xml | |
sed -i "s|app/|/github/workspace/holy-grail-backend/backend/app/|g" coverage.xml | |
sed -i "s|<source>/app</source>|<source>/github/workspace/holy-grail-backend/backend/app</source>|g" coverage.xml | |
- name: Upload coverage to Codecov | |
if: steps.path-filter.outputs.backend == 'true' | |
uses: codecov/codecov-action@v3 | |
with: | |
token: ${{ secrets.CODECOV_TOKEN }} | |
fail_ci_if_error: true | |
verbose: true | |
- name: Build and push Backend Docker image | |
if: steps.path-filter.outputs.backend == 'true' | |
uses: docker/build-push-action@v2 | |
with: | |
context: ./holy-grail-backend/backend | |
push: true | |
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}/holy-grail-backend${{ env.BACKEND_TAG_SUFFIX }}:latest | |
- name: Build and push Scheduler Docker image | |
if: steps.path-filter.outputs.backend == 'true' | |
uses: docker/build-push-action@v2 | |
with: | |
context: ./holy-grail-backend/backend | |
push: true | |
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}/holy-grail-scheduler${{ env.BACKEND_TAG_SUFFIX }}:latest | |
- name: Define tag suffix and Dockerfile for Frontend | |
if: steps.path-filter.outputs.frontend == 'true' | |
run: | | |
if [[ "${{ github.ref }}" == 'refs/heads/master' ]]; then | |
echo "FRONTEND_TAG_SUFFIX=" >> $GITHUB_ENV | |
echo "FRONTEND_DOCKERFILE=Dockerfile.prod" >> $GITHUB_ENV | |
else | |
echo "FRONTEND_TAG_SUFFIX=-dev" >> $GITHUB_ENV | |
echo "FRONTEND_DOCKERFILE=Dockerfile.dev" >> $GITHUB_ENV | |
fi | |
- name: Build and push Frontend Docker image | |
if: steps.path-filter.outputs.frontend == 'true' | |
uses: docker/build-push-action@v2 | |
with: | |
context: ./holy-grail-frontend | |
file: ./holy-grail-frontend/${{ env.FRONTEND_DOCKERFILE }} | |
push: true | |
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}/holy-grail-frontend${{ env.FRONTEND_TAG_SUFFIX }}:latest |