Skip to content

Commit

Permalink
Custom img build flow
Browse files Browse the repository at this point in the history
  • Loading branch information
blelump committed Apr 25, 2023
1 parent 627258a commit eb2bfa4
Show file tree
Hide file tree
Showing 4 changed files with 90 additions and 53 deletions.
56 changes: 56 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
on:
workflow_call:
inputs:
component-name:
required: true
type: string
outputs:
img-tag:
description: "Docker img tag"
value: ${{ jobs.build.outputs.img-tag }}

jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: write
packages: write
outputs:
img-tag: ${{ fromJSON(steps.meta.outputs.json).tags[0] }}
steps:
- uses: actions/checkout@v3

- name: Get tag
id: repository
run: echo "tag=$(git describe --tags HEAD)" > $GITHUB_ENV

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

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

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

- name: Docker meta
id: meta
uses: docker/metadata-action@v4
with:
images: ghcr.io/${{ github.repository_owner }}/keriox-${{inputs.component-name}}
flavor: latest=true
tags: |
type=semver,pattern={{version}}
- name: Build and push
uses: docker/build-push-action@v4
with:
context: .
platforms: linux/amd64
push: true
file: witness.Dockerfile
tags: ${{ steps.meta.outputs.tags }}
File renamed without changes.
53 changes: 34 additions & 19 deletions .github/workflows/docker-images.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,30 +6,45 @@ on:
- v[0-9]+.*

jobs:
build-watcher:
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/') # Running this job only for tags
build-witness:
uses: ./.github/workflows/build.yml
with:
component-name: witness

build-release-witness:
runs-on: ubuntu-latest
needs: build-witness
outputs:
img-tag: ${{ needs.build-witness.outputs.img-tag }}
steps:
- uses: actions/checkout@v2
- run: "echo ${{ needs.build-witness.outputs.img-tag }}"

- name: Build and publish a Docker image for ${{ github.repository }}
uses: macbre/push-to-ghcr@master
with:
image_name: thclab/keriox-watcher
github_token: ${{ secrets.GITHUB_TOKEN }}
dockerfile: watcher.Dockerfile
build-watcher:
uses: ./.github/workflows/build.yml
with:
component-name: watcher

build-witness:
build-release-watcher:
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/') # Running this job only for tags

needs: build-watcher
outputs:
img-tag: ${{ needs.build-watcher.outputs.img-tag }}
steps:
- uses: actions/checkout@v2
- run: "echo ${{ needs.build-watcher.outputs.img-tag }}"

- name: Build and publish a Docker image for ${{ github.repository }}
uses: macbre/push-to-ghcr@master
release:
needs:
- build-release-witness
- build-release-watcher
runs-on: ubuntu-latest
steps:
- name: Release
uses: ncipollo/release-action@v1
with:
image_name: thclab/keriox-witness
github_token: ${{ secrets.GITHUB_TOKEN }}
dockerfile: witness.Dockerfile
body: |
### Images
- Witness: [ ${{ needs.build-release-witness.outputs.img-tag }} ](https://${{needs.build-release-witness.outputs.img-tag}})
- Watcher: [ ${{ needs.build-release-watcher.outputs.img-tag }} ](https://${{needs.build-release-watcher.outputs.img-tag}})
removeArtifacts: true
artifacts: ""
34 changes: 0 additions & 34 deletions .github/workflows/release.yml

This file was deleted.

0 comments on commit eb2bfa4

Please sign in to comment.