Skip to content

Commit

Permalink
fix: add exec to tg2 and rewrite CI
Browse files Browse the repository at this point in the history
  • Loading branch information
uZer committed Jul 19, 2024
1 parent d79078c commit 2e222e7
Show file tree
Hide file tree
Showing 2 changed files with 85 additions and 23 deletions.
104 changes: 82 additions & 22 deletions .github/workflows/docker_build_push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,16 @@ on:
branches:
- main

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
GHCR_IMAGE_NAME: ${{ github.repository }}
DOCKERHUB_IMAGE_NAME: ${{ vars.DOCKERHUB_IMAGE_NAME }}

jobs:
docker_build_and_push:
docker_build:
runs-on: ubuntu-latest
permissions:
packages: write
Expand Down Expand Up @@ -46,35 +50,91 @@ jobs:
uses: docker/metadata-action@a64d0487d7069df33b279515d35d60fa80e2ea62
with:
images: |
${{ env.DOCKERHUB_REPOSITORY }}
ghcr.io/${{ github.repository }}
docker.io/${{ env.DOCKERHUB_IMAGE_NAME }}
ghcr.io/${{ env.GHCR_IMAGE_NAME }}
tags: |
type=sha
labels: |
maintainer=uZer
org.opencontainers.image.title=${{ github.repository }}
org.opencontainers.image.description = "tg2 IRIG-B or WWV timecode generator"
org.opencontainers.image.vendor="${{ env.GITHUB_REPOSITORY_OWNER }}"
org.opencontainers.image.url = "https://github.com/${{ github.repository }}"
org.opencontainers.image.source = "https://github.com/${{ github.repository }}"
org.opencontainers.image.version = "0.0.1"
org.opencontainers.image.created = "${{ github.event.head_commit.timestamp }}"
org.opencontainers.image.revision = "${{ github.sha }}"
org.opencontainers.image.licenses = "MIT"
- name: Build and push Docker image
id: push
org.opencontainers.image.title=${{ env.GHCR_IMAGE_NAME }}
org.opencontainers.image.description="tg2 IRIG-B or WWV timecode generator"
org.opencontainers.image.vendor="${{ github.repository_owner }}"
org.opencontainers.image.url="https://github.com/${{ github.repository }}"
org.opencontainers.image.source="https://github.com/${{ github.repository }}"
org.opencontainers.image.version="0.0.1"
org.opencontainers.image.created="${{ github.event.head_commit.timestamp }}"
org.opencontainers.image.revision="${{ github.sha }}"
org.opencontainers.image.licenses="MIT"
annotations: |
org.opencontainers.image.title=${{ env.GHCR_IMAGE_NAME }}
org.opencontainers.image.description="tg2 IRIG-B or WWV timecode generator"
org.opencontainers.image.vendor="${{ github.repository_owner }}"
org.opencontainers.image.url="https://github.com/${{ github.repository }}"
org.opencontainers.image.source="https://github.com/${{ github.repository }}"
org.opencontainers.image.version="0.0.1"
org.opencontainers.image.created="${{ github.event.head_commit.timestamp }}"
org.opencontainers.image.revision="${{ github.sha }}"
org.opencontainers.image.licenses="MIT"
- name: Build Docker image
id: build
uses: docker/build-push-action@e050dfa622d93dfcc095192a984db567cb14f0f0
with:
context: .
push: true
push: false
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
platforms: ${{ matrix.architecture }}
outputs: type=registry

create_multi_platform_manifest_and_push:
runs-on: ubuntu-latest
needs: docker_build
steps:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Log in to Docker Hub
uses: docker/login-action@0d4c9c5ea7693da7b068278f7b52bda2a190a446
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}

- name: Log in to the Container registry
uses: docker/login-action@0d4c9c5ea7693da7b068278f7b52bda2a190a446
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Create and push multi-platform manifest
id: push
run: |
docker buildx imagetools create \
--tag docker.io/${{ env.DOCKERHUB_IMAGE_NAME }}:${{ github.sha }} \
docker.io/${{ env.DOCKERHUB_IMAGE_NAME }}:${{ github.sha }}-linux/arm/v6 \
docker.io/${{ env.DOCKERHUB_IMAGE_NAME }}:${{ github.sha }}-linux/amd64 \
docker.io/${{ env.DOCKERHUB_IMAGE_NAME }}:${{ github.sha }}-linux/arm64 \
docker.io/${{ env.DOCKERHUB_IMAGE_NAME }}:${{ github.sha }}-linux/arm/v7
docker buildx imagetools create \
--tag ghcr.io/${{ env.GHCR_IMAGE_NAME }}:${{ github.sha }} \
ghcr.io/${{ env.GHCR_IMAGE_NAME }}:${{ github.sha }}-linux/arm/v6 \
ghcr.io/${{ env.GHCR_IMAGE_NAME }}:${{ github.sha }}-linux/amd64 \
ghcr.io/${{ env.GHCR_IMAGE_NAME }}:${{ github.sha }}-linux/arm64 \
ghcr.io/${{ env.GHCR_IMAGE_NAME }}:${{ github.sha }}-linux/arm/v7
- name: Generate artifact attestation (ghcr)
id: push-ghcr
uses: actions/attest-build-provenance@v1
with:
subject-name: ghcr.io/${{ env.GHCR_IMAGE_NAME }}
subject-digest: ${{ needs.docker_build_and_push.outputs.digest }}
push-to-registry: true

- name: Generate artifact attestation
- name: Generate artifact attestation (dockerhub)
id: push-dockerhub
uses: actions/attest-build-provenance@v1
with:
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
subject-digest: ${{ steps.push.outputs.digest }}
subject-name: index.docker.io/${{ env.DOCKERHUB_IMAGE_NAME }}
subject-digest: ${{ needs.docker_build_and_push.outputs.digest }}
push-to-registry: true
4 changes: 3 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,14 @@ RUN set -x \
&& ./configure --without-crypto \
&& make \
&& cd util \
&& make tg2
&& make tg2 \
&& chmod +x tg2

FROM debian:stable-slim

WORKDIR /app

COPY --from=build /tmp/ntp/util/tg2 /app/tg2


ENTRYPOINT ["/app/tg2"]

0 comments on commit 2e222e7

Please sign in to comment.