From c566eabe4656b6093b7c35b70c143ef319311ca7 Mon Sep 17 00:00:00 2001 From: Alfredo Gutierrez Date: Fri, 19 Jul 2024 14:59:55 -0600 Subject: [PATCH] Add a GHA WF for release image publishing, a single WF for both integration and production docker image publishing Signed-off-by: Alfredo Gutierrez --- .github/workflows/release-push-image.yaml | 89 +++++++++++++++++++++++ 1 file changed, 89 insertions(+) create mode 100644 .github/workflows/release-push-image.yaml diff --git a/.github/workflows/release-push-image.yaml b/.github/workflows/release-push-image.yaml new file mode 100644 index 00000000..564e394e --- /dev/null +++ b/.github/workflows/release-push-image.yaml @@ -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 }}