Update Python #1325
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: ci | |
| on: [push] | |
| jobs: | |
| ci: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| packages: write | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| steps: | |
| - uses: actions/checkout@v5 | |
| - run: sudo apt-get install -y --no-install-recommends git-crypt | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - uses: docker/login-action@v3 | |
| if: github.ref == 'refs/heads/main' | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - uses: actions/setup-python@v6 | |
| with: | |
| python-version-file: pyproject.toml | |
| - uses: astral-sh/setup-uv@v6 | |
| with: | |
| version: "0.9.18" | |
| enable-cache: true | |
| - name: Initialize Git | |
| run: | | |
| git config --global user.name "Deployer" | |
| git config --global user.email "it-gruppa@foreningenbs.no" | |
| # This has been added as a deploy key to https://github.com/blindern/deployer-test | |
| # It can easily be regenerated, just remember to add it to the repo. | |
| - name: Install SSH key | |
| env: | |
| GIT_SSH_KEY: ${{ secrets.GIT_SSH_KEY }} | |
| run: | | |
| mkdir -p ~/.ssh | |
| echo "$GIT_SSH_KEY" >~/.ssh/id_rsa | |
| chmod 600 ~/.ssh/id_rsa | |
| - run: uv sync --locked --all-extras --dev | |
| - uses: actions/cache@v4 | |
| with: | |
| path: ~/.cache/pre-commit | |
| key: pre-commit-${{ env.pythonLocation }}-${{ hashFiles('.pre-commit-config.yaml') }} | |
| - run: uv run pre-commit run --all-files | |
| - run: uv run pytest | |
| - name: Build container | |
| id: docker_build | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: . | |
| push: ${{ github.ref == 'refs/heads/main' }} | |
| tags: ghcr.io/blindern/deployer:latest | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| - name: Deploy secondary from primary | |
| if: github.ref == 'refs/heads/main' | |
| run: | | |
| curl --fail -L -i -H "authorization: bearer $DEPLOYER_TOKEN" -H "content-type: application/json" -X POST https://deployer.foreningenbs.no/deploy -d ' | |
| { | |
| "service": "deployer-secondary", | |
| "attributes": { | |
| "image": "ghcr.io/blindern/deployer@${{ steps.docker_build.outputs.digest }}" | |
| } | |
| }' | |
| env: | |
| DEPLOYER_TOKEN: ${{ secrets.DEPLOYER_TOKEN }} | |
| - name: Deploy primary from secondary | |
| if: github.ref == 'refs/heads/main' | |
| run: | | |
| curl --fail -L -i -H "authorization: bearer $DEPLOYER_TOKEN" -H "content-type: application/json" -X POST https://deployer-secondary.foreningenbs.no/deploy -d ' | |
| { | |
| "service": "deployer-primary", | |
| "attributes": { | |
| "image": "ghcr.io/blindern/deployer@${{ steps.docker_build.outputs.digest }}" | |
| } | |
| }' | |
| env: | |
| DEPLOYER_TOKEN: ${{ secrets.DEPLOYER_TOKEN }} |