Skip to content

Commit

Permalink
Add a GHA WF for release image publishing, a single WF for both integ…
Browse files Browse the repository at this point in the history
…ration and production docker image publishing

Signed-off-by: Alfredo Gutierrez <[email protected]>
  • Loading branch information
AlfredoG87 committed Jul 19, 2024
1 parent e39f64d commit d9a73f0
Showing 1 changed file with 89 additions and 0 deletions.
89 changes: 89 additions & 0 deletions .github/workflows/release-push-image.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
name: Release Workflow

on:
push:
# `v*` tags are used for production environment
tags: [ v* ]
# `main` tag is used for integration environment
branches: [ main ]
# Manual trigger with custom release tag
workflow_dispatch:
inputs:
version:
description: 'Release tag:'
type: string
required: false

defaults:
run:
shell: bash

permissions:
contents: read
packages: write

env:
OWNER: hashgraph
PACKAGE_NAME: hedera-block-node
REGISTRY: ghcr.io

jobs:
publish:
runs-on: [self-hosted, Linux, medium, ephemeral]

steps:
- name: Harden Runner
uses: step-security/harden-runner@0d381219ddf674d61a7572ddd19d7941e271515c # v2.9.0
with:
egress-policy: audit

- name: Checkout repository
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7

- name: Get tag
run: |
if [[ "${{ github.event.inputs.version }}" ]]; then
echo "TAG=${{ github.event.inputs.version }}" >> $GITHUB_ENV
elif [[ "$GITHUB_REF_TYPE" == "tag" ]]; then
echo "TAG=${GITHUB_REF#refs/tags/v}" >> $GITHUB_ENV
else
echo "TAG=main" >> $GITHUB_ENV
fi
- name: Install JDK
uses: actions/setup-java@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9 # v4.2.1
with:
distribution: "temurin"
java-version: 21

- name: Setup Gradle
uses: gradle/actions/setup-gradle@d9c87d481d55275bb5441eef3fe0e46805f9ef70 # v3.5.0

- name: Build
run: ./gradlew clean build

- name: Login to GitHub Container Registry
uses: docker/login-action@0d4c9c5ea7693da7b068278f7b52bda2a190a446 # v3.2.0
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Set up Docker Qemu
uses: docker/setup-qemu-action@5927c834f5b4fdf503fca6f4c7eccda82949e1ee # v3.1.0

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@4fd812986e6c8c2a69e18311145f9371337f27d4 # v3.4.0
with:
driver-opts: network=host

- name: Build and push image
uses: docker/build-push-action@1ca370b3a9802c92e886402e0dd88098a2533b12 # v6.4.1
with:
context: ./server/docker
file: ./server/docker/Dockerfile
cache-from: type=gha
cache-to: type=gha,mode=max
platforms: linux/amd64, linux/arm64
push: true
tags: ${{ env.REGISTRY }}/${{ github.repository }}:${{ env.TAG }}

0 comments on commit d9a73f0

Please sign in to comment.