|
| 1 | +--- |
| 2 | +name: Build |
| 3 | + |
| 4 | +env: |
| 5 | + REGISTRY: ghcr.io |
| 6 | + IMAGE_NAME: ${{ "{{" }} github.repository }} |
| 7 | + RELEASE_PYTHON_VERSION: "3.10" |
| 8 | + RELEASE_POETRY_VERSION: "1.2" |
| 9 | + |
| 10 | +on: |
| 11 | + pull_request: |
| 12 | + push: |
| 13 | + branches: |
| 14 | + - '*' |
| 15 | + tags: |
| 16 | + - 'v*' |
| 17 | + workflow_dispatch: |
| 18 | + |
| 19 | +jobs: |
| 20 | + Container: |
| 21 | + runs-on: ubuntu-latest |
| 22 | + permissions: |
| 23 | + contents: read |
| 24 | + packages: write |
| 25 | + |
| 26 | + steps: |
| 27 | + - name: 💾 Check out repository |
| 28 | + uses: actions/checkout@v3 |
| 29 | + |
| 30 | + - name: 🔑 Log in to the container registry |
| 31 | + uses: docker/login-action@v2.1.0 |
| 32 | + with: |
| 33 | + registry: ${{ "{{" }} env.REGISTRY }} |
| 34 | + username: ${{ "{{" }} github.actor }} |
| 35 | + password: ${{ "{{" }} secrets.GITHUB_TOKEN }} |
| 36 | + |
| 37 | + - name: 📡 Collect image metadata |
| 38 | + id: meta |
| 39 | + uses: docker/metadata-action@v4.1.1 |
| 40 | + with: |
| 41 | + images: ${{ "{{" }} env.REGISTRY }}/${{ "{{" }} env.IMAGE_NAME }} |
| 42 | + tags: | |
| 43 | + type=ref,event=branch |
| 44 | + type=ref,event=pr |
| 45 | + type=semver,pattern={{ "{{" }}version}} |
| 46 | + type=semver,pattern={{ "{{" }}major}}.{{ "{{" }}minor}} |
| 47 | + type=semver,pattern={{ "{{" }}major}},enable=${{ "{{" }} !startsWith(github.ref, 'refs/tags/v0.') }} |
| 48 | + type=edge,branch=main |
| 49 | +
|
| 50 | + - name: 🐍 Set up Python project with Poetry |
| 51 | + uses: ./.github/workflows/actions/python-poetry |
| 52 | + with: |
| 53 | + python_version: ${{ "{{" }} env.RELEASE_PYTHON_VERSION }} |
| 54 | + poetry_version: ${{ "{{" }} env.RELEASE_POETRY_VERSION }} |
| 55 | + |
| 56 | + - name: 🔥 Test |
| 57 | + run: poetry run poe test |
| 58 | + |
| 59 | + - name: 📦 Build and publish container image |
| 60 | + uses: docker/build-push-action@v3.2.0 |
| 61 | + with: |
| 62 | + context: . |
| 63 | + push: ${{ "{{" }} github.event_name != 'pull_request' }} |
| 64 | + tags: ${{ "{{" }} steps.meta.outputs.tags }} |
| 65 | + labels: ${{ "{{" }} steps.meta.outputs.labels }} |
0 commit comments