diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 06fb40f..6e18aba 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -1,8 +1,8 @@ ---- -name: Build and publish docker container image to GitHub's container registry +name: Build Docker images on: - workflow_dispatch: + release: + types: [published] schedule: - cron: "0 0 * * 0" push: @@ -11,15 +11,11 @@ on: env: REGISTRY: ghcr.io - IMAGE_NAME: "${{ github.repository_owner }}/raybeam:edge" + IMAGE_NAME: "${{ github.repository_owner }}/raybeam" jobs: - build: - name: Build image + docker: runs-on: ubuntu-latest - permissions: - contents: read - packages: write steps: - uses: actions/checkout@v3 @@ -34,11 +30,24 @@ jobs: id: cache with: path: /tmp/.buildx-cache - key: ${{ runner.os }}-buildx-${{ matrix.service }}-${{ github.sha }} + key: ${{ runner.os }}-buildx-${{ github.sha }} restore-keys: | - ${{ runner.os }}-buildx-${{ matrix.service }} ${{ runner.os }}-buildx- + - name: Gather Docker metadata + id: meta + uses: docker/metadata-action@v4 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + tags: | + type=ref,event=branch + type=ref,event=pr + type=semver,pattern={{version}} + type=semver,pattern={{version}}.{{major}} + labels: | + cache-from=type=local,src=/tmp/.buildx-cache + cache-to=type=local,dest=/tmp/.buildx-cache + - name: Log in to the Container registry uses: docker/login-action@v2 with: @@ -50,8 +59,6 @@ jobs: uses: docker/build-push-action@v4 with: push: true - tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} platforms: linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64 - labels: | - cache-from: type=local,src=/tmp/.buildx-cache - cache-to: type=local,dest=/tmp/.buildx-cache diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 3040c13..36a22c1 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -2,18 +2,14 @@ name: Create GitHub release on: release: - types: [ published ] - -env: - REGISTRY: ghcr.io - IMAGE_NAME: "${{ github.repository_owner }}/raybeam" + types: [published] jobs: release: strategy: fail-fast: false matrix: - goos: [ linux, darwin ] + goos: [linux, darwin] runs-on: ubuntu-latest steps: - name: Checkout code @@ -25,44 +21,3 @@ jobs: github_token: ${{ secrets.GITHUB_TOKEN }} goos: ${{ matrix.goos }} goarch: amd64 - - docker: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - - name: Set up QEMU - uses: docker/setup-qemu-action@v2 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 - - - name: Cache docker layers - uses: actions/cache@v3 - id: cache - with: - path: /tmp/.buildx-cache - key: ${{ runner.os }}-buildx-${{ matrix.service }}-${{ github.sha }} - restore-keys: | - ${{ runner.os }}-buildx-${{ matrix.service }} - ${{ runner.os }}-buildx- - - - name: Log in to the Container registry - uses: docker/login-action@v2 - with: - registry: ${{ env.REGISTRY }} - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: Set release version - run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV - - - name: Build and push Docker image - uses: docker/build-push-action@v4 - with: - push: true - tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest,${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.RELEASE_VERSION }} - platforms: linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64 - labels: | - cache-from: type=local,src=/tmp/.buildx-cache - cache-to: type=local,dest=/tmp/.buildx-cache