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

Commit

Permalink
Adds GitHub workflow (#8)
Browse files Browse the repository at this point in the history
* adds github workflow
---------

Co-authored-by: Jens Plüddemann <[email protected]>
  • Loading branch information
JenSeReal and Jens Plüddemann authored Apr 15, 2024
1 parent 82c49a6 commit 8b2a1e7
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 2 deletions.
64 changes: 64 additions & 0 deletions .github/workflows/docker-build-and-push.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: Create and publish a Docker image

on:
push:
branches: ["**"] # run for any commit or tag push on any branch
tags-ignore: ["v**"] # reserve v* tags for releases

jobs:
build-and-push-image:
name: Build and publish docker images
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- dockerfile: Dockerfile
image: ghcr.io/${{ github.repository }}-application
context: .
- dockerfile: tutorial/Dockerfile
image: ghcr.io/${{ github.repository }}-tutorial
context: tutorial
permissions:
contents: read
packages: write

steps:
- name: Checkout repository
uses: actions/checkout@v4

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

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

- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ matrix.image }}
tags: |
type=ref,event=branch
type=ref,event=tag
type=ref,event=pr
type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'main') }}
- name: Build and Push Digest
id: build
uses: docker/build-push-action@v5
with:
context: ${{ matrix.context }}
file: ${{ matrix.dockerfile }}
platforms: linux/amd64, linux/arm64
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
push: true
4 changes: 2 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
services:
application:
image: ghcr.io/jensereal/otel-getting-started-application:adds-github-workflow
build:
context: .
dockerfile: Dockerfile
image: otel-getting-started-application:latest
tty: true
volumes:
- ./labs:/workspace
Expand All @@ -14,7 +14,7 @@ services:
image: kennethreitz/httpbin

tutorial:
image: otel-getting-started-tutorial:latest
image: ghcr.io/jensereal/otel-getting-started-tutorial:adds-github-workflow
build:
context: tutorial/
dockerfile: Dockerfile
Expand Down

0 comments on commit 8b2a1e7

Please sign in to comment.