name: 'ci'

on:
  push:
    branches:
    - master

jobs:
  dagger:
    runs-on: ubuntu-latest
    steps:
      -
        name: Checkout
        uses: actions/checkout@v3
      -
        id: 'auth'
        name: 'Authenticate to Google Cloud'
        uses: 'google-github-actions/auth@v1'
        with:
          token_format: 'access_token'
          credentials_json: '${{ secrets.GOOGLE_CREDENTIALS }}'
      -
        name: Login to Google Container Registry
        uses: docker/login-action@v2
        with:
          registry: gcr.io
          username: oauth2accesstoken
          password: ${{ steps.auth.outputs.access_token }}
      -
        name: Setup Python
        uses: actions/setup-python@v4
        with:
          python-version: '3.10'
      -
        name: Install
        run: pip install dagger-io google-cloud-run
      -
        name: Install Dagger CLI
        run: cd /usr/local && { curl -L https://dl.dagger.io/dagger/install.sh | sh; cd -; }
      -
        name: Release and deploy with Dagger
        run: dagger run python ci/main.py
