|
| 1 | +name: Docker build and push images |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + push: |
| 8 | + branches: |
| 9 | + - main |
| 10 | + tags: |
| 11 | + - "v*" |
| 12 | + |
| 13 | +concurrency: |
| 14 | + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} |
| 15 | + cancel-in-progress: true |
| 16 | + |
| 17 | +jobs: |
| 18 | + build: |
| 19 | + name: docker builds |
| 20 | + permissions: |
| 21 | + packages: write |
| 22 | + contents: read |
| 23 | + runs-on: ubuntu-latest |
| 24 | + steps: |
| 25 | + - name: Check out code |
| 26 | + uses: actions/checkout@v4 |
| 27 | + with: |
| 28 | + fetch-depth: 0 |
| 29 | + ref: ${{ github.event.pull_request.head.sha }} |
| 30 | + |
| 31 | + - name: Set up QEMU |
| 32 | + uses: docker/setup-qemu-action@v2 |
| 33 | + |
| 34 | + - name: Set up Docker Buildx |
| 35 | + uses: docker/setup-buildx-action@v2 |
| 36 | + |
| 37 | + - name: Log in to the Container registry |
| 38 | + uses: docker/login-action@v2 |
| 39 | + with: |
| 40 | + registry: ghcr.io |
| 41 | + username: ${{ github.actor }} |
| 42 | + password: ${{ github.token }} |
| 43 | + |
| 44 | + - name: Extract metadata (tags, labels) for Docker |
| 45 | + id: meta |
| 46 | + uses: docker/metadata-action@v4 |
| 47 | + with: |
| 48 | + images: | |
| 49 | + ghcr.io/${{ github.repository }} |
| 50 | + tags: | |
| 51 | + type=sha |
| 52 | + type=ref,event=pr |
| 53 | + type=ref,event=tag |
| 54 | + type=sha,format=long |
| 55 | + type=ref,event=branch |
| 56 | + type=semver,pattern={{version}},prefix=v |
| 57 | + type=semver,pattern={{major}}.{{minor}},prefix=v |
| 58 | + type=raw,value=latest,enable={{is_default_branch}} |
| 59 | + type=raw,value=${{ github.event.pull_request.head.ref }} |
| 60 | + type=raw,value=stable,enable=${{ startsWith(github.event.ref, 'refs/tags/v') }} |
| 61 | +
|
| 62 | + - name: Build and push livepeer docker image |
| 63 | + uses: docker/build-push-action@v6 |
| 64 | + with: |
| 65 | + build-args: | |
| 66 | + VERSION=${{ (github.ref_type == 'tag' && github.ref_name) || (github.event.pull_request.head.sha || github.sha) }} |
| 67 | + GITHUB_SHA=${{ (github.event.pull_request.head.sha || github.sha) }} |
| 68 | + context: . |
| 69 | + platforms: linux/amd64 |
| 70 | + tags: ${{ steps.meta.outputs.tags }} |
| 71 | + file: docker/Dockerfile |
| 72 | + labels: ${{ steps.meta.outputs.labels }} |
| 73 | + cache-from: type=gha |
| 74 | + cache-to: type=gha,mode=max |
| 75 | + annotations: ${{ steps.meta.outputs.annotations }} |
| 76 | + |
| 77 | + - name: Notify new build upload |
| 78 | + run: curl -X POST https://holy-bread-207a.livepeer.workers.dev |
0 commit comments