Skip to content

Commit

Permalink
feat: added action to reuse building images for release and main
Browse files Browse the repository at this point in the history
  • Loading branch information
Kammerlo committed May 7, 2024
1 parent 697941d commit ef0f96a
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 54 deletions.
63 changes: 63 additions & 0 deletions .github/actions/build_docker_images/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: Build Docker images
description: Builds and pushes Docker images for the Cardano Rosetta project including API, Indexer and All-in-one Image
inputs:
tag:
description: Docker tag
required: true
default: main
isRelease:
description: Is this a release build? If true, the latest tag will be applied
required: false
default: false
runs:
using: composite
steps:
- name: Checkout
uses: actions/checkout@v3
ref: ${{ inputs.tag }}
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: [ API ] Build and push Docker ${{ inputs.tag }} image
uses: docker/build-push-action@v4
with:
file: ./api/Dockerfile
tags: cardanofoundation/cardano-rosetta-java-api:${{ inputs.tag }}
push: true
- name: [ API ] Build and push Docker latest image
uses: docker/build-push-action@v4
if: ${{ inputs.isRelease == 'true' }}
with:
file: ./api/Dockerfile
tags: cardanofoundation/cardano-rosetta-java-api:latest
push: true
- name: [ Indexer ] Build and push Docker ${{ inputs.tag }} image
uses: docker/build-push-action@v4
with:
file: ./yaci-indexer/Dockerfile
tags: cardanofoundation/cardano-rosetta-java-indexer:${{ inputs.tag }}
push: true
- name: [ Indexer ] Build and push Docker latest image
uses: docker/build-push-action@v4
if: ${{ inputs.isRelease == 'true' }}
with:
file: ./api/Dockerfile
tags: cardanofoundation/cardano-rosetta-java-indexer:latest
push: true
# TODO will be added when the all-in-one image is ready
# - name: [All-in-one] Build and push Docker image
# uses: docker/build-push-action@v4
# with:
# file: ./Dockerfile
# tags: cardanofoundation/cardano-rosetta-java:${{ inputs.tag }}
# push: true
# - name: [ All-in-one ] Build and push Docker latest image
# uses: docker/build-push-action@v4
# if: ${{ inputs.isRelease == 'true' }}
# with:
# file: ./Dockerfile
# tags: cardanofoundation/cardano-rosetta-java:latest
# push: true
31 changes: 4 additions & 27 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,36 +2,13 @@ name: Build main branch

on:
push:
branches: [ main ]
branches: [ main, feat/RA-64-Containerisation-for-Distribution ]

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
- name: Build Cardano Rosetta Release
uses: ./.github/actions/build_docker_images
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: [API] Build and push Docker image
uses: docker/build-push-action@v4
with:
file: ./api/Dockerfile
tags: cardanofoundation/cardano-rosetta-java-api:main
push: true
- name: [Indexer] Build and push Docker image
uses: docker/build-push-action@v4
with:
file: ./yaci-indexer/Dockerfile
tags: cardanofoundation/cardano-rosetta-java-indexer:main
push: true
# TODO will be added when the all-in-one image is ready
# - name: [All-in-one] Build and push Docker image
# uses: docker/build-push-action@v4
# with:
# file: ./Dockerfile
# tags: cardanofoundation/cardano-rosetta-java:main
# push: true
tag: ${{ github.event.release.tag_name }}
31 changes: 4 additions & 27 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,31 +9,8 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
ref: ${{github.event.release.tag_name}}
- name: Login to Docker Hub
uses: docker/login-action@v3
- name: Build Cardano Rosetta Release
uses: ./.github/actions/build_docker_images
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: [API] Build and push Docker image
uses: docker/build-push-action@v4
with:
file: ./api/Dockerfile
tags: cardanofoundation/cardano-rosetta-java-api:${{github.event.release.tag_name}},cardanofoundation/cardano-rosetta-java-api:latest
push: true
- name: [Indexer] Build and push Docker image
uses: docker/build-push-action@v4
with:
file: ./yaci-indexer/Dockerfile
tags: cardanofoundation/cardano-rosetta-java-indexer:${{github.event.release.tag_name}},cardanofoundation/cardano-rosetta-java-indexer:latest
push: true
# TODO will be added when the all-in-one image is ready
# - name: [All-in-one] Build and push Docker image
# uses: docker/build-push-action@v4
# with:
# file: ./Dockerfile
# tags: cardanofoundation/cardano-rosetta-java:${{github.event.release.tag_name}}
# push: true
tag: ${{ github.event.release.tag_name }}
isRelease: true

0 comments on commit ef0f96a

Please sign in to comment.