Skip to content

Commit

Permalink
refactor: improve the provided Docker image tags built by CI
Browse files Browse the repository at this point in the history
  • Loading branch information
TheDevMinerTV committed Jun 23, 2023
1 parent 9423448 commit 0e5f194
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 62 deletions.
37 changes: 22 additions & 15 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -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:
Expand All @@ -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

Expand All @@ -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:
Expand All @@ -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
49 changes: 2 additions & 47 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

0 comments on commit 0e5f194

Please sign in to comment.