Merge pull request #878 from Meepu/kotae-badges #6
This file contains hidden or 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: backend | |
| on: | |
| push: | |
| paths: | |
| - kompassi/** | |
| - kubernetes/** | |
| - .github/workflows/backend.yaml | |
| - Dockerfile | |
| - Dockerfile.static | |
| - manage.py | |
| - pyproject.toml | |
| - uv.lock | |
| - skaffold.in.yaml | |
| branches: | |
| - main | |
| pull_request: | |
| paths: | |
| - kompassi/** | |
| - kubernetes/** | |
| - .github/workflows/backend.yaml | |
| - Dockerfile | |
| - Dockerfile.static | |
| - manage.py | |
| - pyproject.toml | |
| - uv.lock | |
| - skaffold.in.yaml | |
| branches: | |
| - main | |
| permissions: | |
| contents: read | |
| packages: write | |
| jobs: | |
| test: | |
| runs-on: ubuntu-latest | |
| env: | |
| DOCKER_BUILDKIT: "1" | |
| COMPOSE_DOCKER_CLI_BUILD: "1" | |
| UV_PYTHON_DOWNLOADS: "0" | |
| steps: | |
| - uses: actions/checkout@v5 | |
| - uses: docker/setup-buildx-action@v3 | |
| - run: docker compose -f docker-compose.test.yml up --exit-code-from test | |
| build: | |
| runs-on: ubuntu-latest | |
| if: ${{ github.event_name == 'push' }} | |
| env: | |
| SKAFFOLD_DEFAULT_REPO: ghcr.io/con2 | |
| steps: | |
| - uses: actions/checkout@v5 | |
| - uses: astral-sh/setup-uv@v6 | |
| with: | |
| enable-cache: true | |
| - uses: actions/setup-python@v6 | |
| with: | |
| python-version-file: ".python-version" | |
| - id: cache-bin | |
| uses: actions/cache@v4 | |
| with: | |
| path: bin | |
| key: ${{ runner.os }}-bin-2 | |
| - if: steps.cache-bin.outputs.cache-hit != 'true' | |
| run: | | |
| mkdir bin | |
| curl -Lo bin/skaffold https://storage.googleapis.com/skaffold/releases/latest/skaffold-linux-amd64 | |
| curl -Lo bin/kubectl https://dl.k8s.io/release/v1.22.0/bin/linux/amd64/kubectl | |
| chmod +x bin/skaffold bin/kubectl | |
| - run: echo "$PWD/bin" >> $GITHUB_PATH | |
| - if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }} | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - uses: docker/setup-buildx-action@v3 | |
| - id: build | |
| run: | | |
| # only push to ghcr.io on push to main | |
| if ! [[ "$GITHUB_EVENT_NAME" == 'push' && "$GITHUB_REF" == 'refs/heads/main' ]]; then | |
| export SKAFFOLD_PUSH=false | |
| fi | |
| uv run --no-project --with emskaffolden==0.3.0 emskaffolden -E staging -- build --file-output build.json | |
| - uses: actions/upload-artifact@v4 | |
| with: | |
| name: build-json | |
| path: build.json | |
| # TODO DRY | |
| deploy_staging: | |
| runs-on: self-hosted | |
| needs: build | |
| environment: staging | |
| if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }} | |
| steps: | |
| - uses: actions/checkout@v5 | |
| - uses: actions/download-artifact@v5 | |
| with: | |
| name: build-json | |
| - uses: astral-sh/setup-uv@v6 | |
| with: | |
| enable-cache: true | |
| - uses: actions/setup-python@v6 | |
| with: | |
| python-version-file: ".python-version" | |
| - id: cache-bin | |
| uses: actions/cache@v4 | |
| with: | |
| path: bin | |
| key: ${{ runner.os }}-bin-2 | |
| - if: steps.cache-bin.outputs.cache-hit != 'true' | |
| run: | | |
| mkdir bin | |
| curl -Lo bin/skaffold https://storage.googleapis.com/skaffold/releases/latest/skaffold-linux-amd64 | |
| curl -Lo bin/kubectl https://dl.k8s.io/release/v1.22.0/bin/linux/amd64/kubectl | |
| chmod +x bin/skaffold bin/kubectl | |
| - run: echo "$PWD/bin" >> $GITHUB_PATH | |
| - run: | | |
| uv run --no-project --with emskaffolden==0.3.0 emskaffolden -E staging -- deploy -n kompassi-staging -a build.json | |
| deploy_production: | |
| runs-on: self-hosted | |
| needs: build | |
| environment: production | |
| if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }} | |
| steps: | |
| - uses: actions/checkout@v5 | |
| - uses: actions/download-artifact@v5 | |
| with: | |
| name: build-json | |
| - uses: astral-sh/setup-uv@v6 | |
| with: | |
| enable-cache: true | |
| - uses: actions/setup-python@v6 | |
| with: | |
| python-version-file: ".python-version" | |
| - id: cache-bin | |
| uses: actions/cache@v4 | |
| with: | |
| path: bin | |
| key: ${{ runner.os }}-bin-2 | |
| - if: steps.cache-bin.outputs.cache-hit != 'true' | |
| run: | | |
| mkdir bin | |
| curl -Lo bin/skaffold https://storage.googleapis.com/skaffold/releases/latest/skaffold-linux-amd64 | |
| curl -Lo bin/kubectl https://dl.k8s.io/release/v1.22.0/bin/linux/amd64/kubectl | |
| chmod +x bin/skaffold bin/kubectl | |
| - run: echo "$PWD/bin" >> $GITHUB_PATH | |
| - run: | | |
| uv run --no-project --with emskaffolden==0.3.0 emskaffolden -E production -- deploy -n kompassi-production -a build.json |