|
| 1 | +name: build python |
| 2 | +on: |
| 3 | + workflow_dispatch: |
| 4 | + workflow_run: |
| 5 | + workflows: ['base.yml'] |
| 6 | + types: [completed] |
| 7 | + branches: |
| 8 | + - master |
| 9 | + push: |
| 10 | + branches: |
| 11 | + - master |
| 12 | + paths: |
| 13 | + - python/** |
| 14 | + |
| 15 | +permissions: |
| 16 | + contents: read |
| 17 | + packages: write |
| 18 | + |
| 19 | +jobs: |
| 20 | + check_changes: |
| 21 | + runs-on: ubuntu-latest |
| 22 | + outputs: |
| 23 | + only_python: ${{ steps.filter.outputs.only_python || 'false' }} |
| 24 | + steps: |
| 25 | + - if: ${{ github.event_name == 'push' }} |
| 26 | + uses: actions/checkout@v4 |
| 27 | + with: |
| 28 | + fetch-depth: 0 |
| 29 | + - if: ${{ github.event_name == 'push' }} |
| 30 | + id: filter |
| 31 | + uses: dorny/paths-filter@v3 |
| 32 | + with: |
| 33 | + filters: | |
| 34 | + only_python: |
| 35 | + - 'python/**' |
| 36 | + - '!base/**' |
| 37 | + - '!scripts/ampstart.sh' |
| 38 | +
|
| 39 | + build_and_push: |
| 40 | + needs: [check_changes] |
| 41 | + if: ${{ github.repository_owner == 'CubeCoders' && ( (github.event_name == 'workflow_run' && github.event.workflow_run.conclusion == 'success') || (github.event_name == 'push' && needs.check_changes.outputs.only_python == 'true') || github.event_name == 'workflow_dispatch' ) }} |
| 42 | + name: "amp:python-${{ matrix.python }}" |
| 43 | + runs-on: ubuntu-latest |
| 44 | + strategy: |
| 45 | + fail-fast: false |
| 46 | + matrix: |
| 47 | + python: |
| 48 | + - '3' |
| 49 | + |
| 50 | + steps: |
| 51 | + - uses: actions/checkout@v4 |
| 52 | + with: |
| 53 | + ref: ${{ github.event_name == 'workflow_run' && github.event.workflow_run.head_sha || github.sha }} |
| 54 | + |
| 55 | + - uses: docker/setup-qemu-action@v3 |
| 56 | + - uses: docker/setup-buildx-action@v3 |
| 57 | + |
| 58 | + - uses: docker/login-action@v3 |
| 59 | + with: |
| 60 | + registry: ghcr.io |
| 61 | + username: cubecoders |
| 62 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 63 | + |
| 64 | + - uses: docker/build-push-action@v6 |
| 65 | + with: |
| 66 | + context: . |
| 67 | + file: ./python/${{ matrix.python }}/Dockerfile |
| 68 | + platforms: linux/amd64,linux/arm64/v8 |
| 69 | + push: true |
| 70 | + pull: true |
| 71 | + tags: ghcr.io/cubecoders/amp:python-${{ matrix.python }} |
| 72 | + cache-from: type=gha,scope=${{ github.workflow }}-${{ matrix.python }} |
| 73 | + cache-to: type=gha,mode=max,scope=${{ github.workflow }}-${{ matrix.python }} |
| 74 | + provenance: mode=max |
| 75 | + sbom: true |
| 76 | + |
| 77 | +concurrency: |
| 78 | + group: ${{ github.workflow }}-${{ github.ref }} |
| 79 | + cancel-in-progress: false |
0 commit comments