Skip to content

module 4 setUp

module 4 setUp #20

Workflow file for this run

name: game-service CI/CD

Check failure on line 1 in .github/workflows/game-service.yml

View workflow run for this annotation

GitHub Actions / .github/workflows/game-service.yml

Invalid workflow file

(Line: 56, Col: 9): Unrecognized function: 'hashFiles'. Located at position 36 within expression: github.ref == 'refs/heads/main' && hashFiles('services/game-service/Dockerfile') != ''
on:
push:
paths:
- "services/game-service/**"
- ".github/workflows/game-service.yml"
pull_request:
paths:
- "services/game-service/**"
- ".github/workflows/game-service.yml"
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository_owner }}/gamehub-game-service
jobs:
lint:
name: Lint
runs-on: ubuntu-latest
defaults:
run:
working-directory: services/game-service
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.12"
cache: pip
- run: pip install ruff mypy
- run: ruff check app/
- run: mypy app/ --ignore-missing-imports
test:
name: Test
runs-on: ubuntu-latest
defaults:
run:
working-directory: services/game-service
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.12"
cache: pip
- run: pip install -r requirements.txt
- name: Run tests
env:
DATABASE_URL: sqlite:///./test.db
run: pytest tests/ -v --tb=short
build-and-push:
name: Build & Push
runs-on: ubuntu-latest
needs: [lint, test]
if: github.ref == 'refs/heads/main' && hashFiles('services/game-service/Dockerfile') != ''
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v4
- uses: docker/setup-buildx-action@v3
- uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: docker/metadata-action@v5
id: meta
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=sha,prefix=sha-
type=raw,value=latest,enable={{is_default_branch}}
- uses: docker/build-push-action@v5
with:
context: services/game-service
target: runtime
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max