Skip to content
This repository has been archived by the owner on Oct 20, 2024. It is now read-only.

Commit

Permalink
Publish v1
Browse files Browse the repository at this point in the history
  • Loading branch information
derogab committed Oct 17, 2021
1 parent ab581b0 commit dc4541f
Showing 1 changed file with 170 additions and 25 deletions.
195 changes: 170 additions & 25 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Docker
name: Build & Push Docker Image

# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
Expand All @@ -21,7 +21,8 @@ on:

env:
# Use docker.io for Docker Hub if empty
REGISTRY: ghcr.io
GITHUB_REGISTRY: ghcr.io
DOCKER_REGISTRY: docker.io
# github.repository as <account>/<repo>
IMAGE_NAME_DAEMON: ${{ github.repository }}-daemon
IMAGE_NAME_CLIENT: ${{ github.repository }}-client
Expand All @@ -30,7 +31,8 @@ env:
jobs:

# Run tests.
test:
test-daemon:
name: Test Daemon
runs-on: ubuntu-latest

steps:
Expand All @@ -43,15 +45,31 @@ jobs:
docker-compose --file docker-compose.test.yml run sut
else
docker build ./daemon/ --file Dockerfile
fi
test-client:
name: Test Client
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- name: Run tests
run: |
if [ -f docker-compose.test.yml ]; then
docker-compose --file docker-compose.test.yml build
docker-compose --file docker-compose.test.yml run sut
else
docker build . --file Dockerfile
fi
# Push daemon image to GitHub Packages.
push-daemon:
push-daemon-to-github-packages:

# Ensure test job passes before pushing image.
needs: test
needs: test-daemon

name: Build Daemon & Push to GitHub Registry
runs-on: ubuntu-latest
permissions:
contents: read
Expand All @@ -69,39 +87,46 @@ jobs:

# Login against a Docker registry except on PR
# https://github.com/docker/login-action
- name: Log into registry ${{ env.REGISTRY }}
- name: Log into registry ${{ env.GITHUB_REGISTRY }}
if: github.event_name != 'pull_request'
uses: docker/login-action@28218f9b04b4f3f62068d7b6ce6ca5b26e35336c
uses: docker/login-action@v1
with:
registry: ${{ env.REGISTRY }}
registry: ${{ env.GITHUB_REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

# Extract metadata (tags, labels) for Docker
# https://github.com/docker/metadata-action
- name: Extract Docker metadata
id: metad
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
id: meta
uses: docker/metadata-action@v3
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME_DAEMON }}
images: ${{ env.GITHUB_REGISTRY }}/${{ env.IMAGE_NAME_DAEMON }}
tags: |
type=ref,event=branch
type=semver,pattern={{version}}
type=semver,pattern={{major}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}.{{minor}}.{{patch}}
# Build and push Docker image with Buildx (don't push on PR)
# https://github.com/docker/build-push-action
- name: Build and push Docker image
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
uses: docker/build-push-action@v2
with:
context: ./daemon/
platforms: linux/amd64,linux/arm64,linux/arm/v7
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.metad.outputs.tags }}
labels: ${{ steps.metad.outputs.labels }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

# Push client image to GitHub Packages.
push-client:
push-client-to-github-packages:

# Ensure test job passes before pushing image.
needs: test
needs: test-client

name: Build Client & Push to GitHub Registry
runs-on: ubuntu-latest
permissions:
contents: read
Expand All @@ -119,29 +144,149 @@ jobs:

# Login against a Docker registry except on PR
# https://github.com/docker/login-action
- name: Log into registry ${{ env.REGISTRY }}
- name: Log into registry ${{ env.GITHUB_REGISTRY }}
if: github.event_name != 'pull_request'
uses: docker/login-action@28218f9b04b4f3f62068d7b6ce6ca5b26e35336c
uses: docker/login-action@v1
with:
registry: ${{ env.REGISTRY }}
registry: ${{ env.GITHUB_REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

# Extract metadata (tags, labels) for Docker
# https://github.com/docker/metadata-action
- name: Extract Docker metadata
id: metac
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
id: meta
uses: docker/metadata-action@v3
with:
images: ${{ env.GITHUB_REGISTRY }}/${{ env.IMAGE_NAME_CLIENT }}
tags: |
type=ref,event=branch
type=semver,pattern={{version}}
type=semver,pattern={{major}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}.{{minor}}.{{patch}}
# Build and push Docker image with Buildx (don't push on PR)
# https://github.com/docker/build-push-action
- name: Build and push Docker image
uses: docker/build-push-action@v2
with:
context: .
platforms: linux/amd64,linux/arm64,linux/arm/v7
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

# Push daemon image to Docker Hub.
push-daemon-to-docker-hub:

# Ensure test job passes before pushing image.
needs: test-daemon

name: Build Daemon & Push to Docker Hub
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

steps:
- name: Checkout
uses: actions/checkout@v2

- name: Set up QEMU
uses: docker/setup-qemu-action@v1

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

# Login against a Docker registry except on PR
# https://github.com/docker/login-action
- name: Log into registry ${{ env.DOCKER_REGISTRY }}
if: github.event_name != 'pull_request'
uses: docker/login-action@v1
with:
registry: ${{ env.DOCKER_REGISTRY }}
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

# Extract metadata (tags, labels) for Docker
# https://github.com/docker/metadata-action
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v3
with:
images: ${{ env.IMAGE_NAME_DAEMON }}
tags: |
type=ref,event=branch
type=semver,pattern={{version}}
type=semver,pattern={{major}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}.{{minor}}.{{patch}}
# Build and push Docker image with Buildx (don't push on PR)
# https://github.com/docker/build-push-action
- name: Build and push Docker image
uses: docker/build-push-action@v2
with:
context: ./daemon/
platforms: linux/amd64,linux/arm64,linux/arm/v7
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

# Push client image to Docker Hub.
push-client-to-docker-hub:

# Ensure test job passes before pushing image.
needs: test-client

name: Build Client & Push to Docker Hub
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

steps:
- name: Checkout
uses: actions/checkout@v2

- name: Set up QEMU
uses: docker/setup-qemu-action@v1

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

# Login against a Docker registry except on PR
# https://github.com/docker/login-action
- name: Log into registry ${{ env.DOCKER_REGISTRY }}
if: github.event_name != 'pull_request'
uses: docker/login-action@v1
with:
registry: ${{ env.DOCKER_REGISTRY }}
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

# Extract metadata (tags, labels) for Docker
# https://github.com/docker/metadata-action
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v3
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME_CLIENT }}
images: ${{ env.IMAGE_NAME_CLIENT }}
tags: |
type=ref,event=branch
type=semver,pattern={{version}}
type=semver,pattern={{major}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}.{{minor}}.{{patch}}
# Build and push Docker image with Buildx (don't push on PR)
# https://github.com/docker/build-push-action
- name: Build and push Docker image
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
uses: docker/build-push-action@v2
with:
context: .
platforms: linux/amd64,linux/arm64,linux/arm/v7
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.metac.outputs.tags }}
labels: ${{ steps.metac.outputs.labels }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

0 comments on commit dc4541f

Please sign in to comment.