Skip to content

Commit

Permalink
github/workflows: add multi platform docker image (#348)
Browse files Browse the repository at this point in the history
Adds multi-platform support for docker image using https://github.com/docker/build-push-action.

category: bug 
ticket: #339
  • Loading branch information
dB2510 authored Apr 6, 2022
1 parent b029922 commit aa154e1
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 32 deletions.
32 changes: 20 additions & 12 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,34 @@ jobs:
runs-on: ubuntu-latest
name: Build Docker Image
steps:

- uses: actions/checkout@v2

- uses: docker/setup-buildx-action@v1

- id: get-version
run: |
version=$(echo "${{ github.sha }}" | cut -c1-8)
echo "::set-output name=version::$version"
- name: Publish to registry
uses: elgohr/Publish-Docker-Github-Action@3.04
env:
NODE_ENV: production
DOCKER_BUILDKIT: 1
- id: meta
uses: docker/metadata-action@v3
with:
images: |
ghcr.io/obolnetwork/charon/charon
tags: "latest,${{steps.get-version.outputs.version}}"

- uses: docker/login-action@v1
with:
name: ${{ github.repository }}/charon
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.CONTAINER_REGISTRY_SECRET }}
buildargs: GITHUB_SHA=${{ github.sha }}
registry: ghcr.io
tags: "latest,${{steps.get-version.outputs.version}}"

- name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }}
- uses: docker/build-push-action@v2
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
build-args: GITHUB_SHA=${{ github.sha }}
tags: ${{ steps.meta.outputs.tags }}

- run: echo ${{ steps.docker_build.outputs.digest }}
47 changes: 27 additions & 20 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,38 +10,45 @@ jobs:
steps:
- uses: actions/checkout@v2

- id: get-version
- uses: docker/setup-buildx-action@v1

- id: get-tag
run: |
version=$(echo "${{ github.ref }}" | cut -d / -f 3)
echo "::set-output name=version::$version"
- name: Publish to registry
uses: elgohr/Publish-Docker-Github-Action@3.02
env:
NODE_ENV: production
DOCKER_BUILDKIT: 1
tag=$(echo "${{ github.ref }}" | cut -d / -f 3)
echo "::set-output name=tag::$tag"
- id: meta
uses: docker/metadata-action@v3
with:
images: |
ghcr.io/obolnetwork/charon/charon
tags: "${{steps.get-tag.outputs.tag}}"

- uses: docker/login-action@v1
with:
name: ${{ github.repository }}/charon
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.CONTAINER_REGISTRY_SECRET }}
buildargs: GITHUB_SHA=${{ github.sha }}
registry: ghcr.io
tags: "${{ steps.get-version.outputs.version }}"

- name: Generate cli reference
run: docker run ghcr.io/obolnetwork/charon/charon:${{steps.get-version.outputs.version}} charon run --help > cli-reference.txt
- uses: docker/build-push-action@v2
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
build-args: GITHUB_SHA=${{ github.sha }}
tags: ${{ steps.meta.outputs.tags }}

- run: docker run ghcr.io/obolnetwork/charon/charon:${{steps.get-tag.outputs.tag}} charon run --help > cli-reference.txt

- name: View cli reference
run: cat cli-reference.txt
- run: cat cli-reference.txt

- name: Release
uses: softprops/action-gh-release@v1
- uses: softprops/action-gh-release@v1
with:
files: cli-reference.txt
body: |
![Obol Logo](https://obol.tech/obolnetwork.png)
Charon client version `${{steps.get-version.outputs.version}}`.
Charon client version `${{steps.get-tag.outputs.tag}}`.
###### This software is in beta, use with caution
token: ${{ secrets.RELEASE_SECRET }}

0 comments on commit aa154e1

Please sign in to comment.