Docker Image #191
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Docker Image | |
on: | |
workflow_dispatch: | |
inputs: | |
guild_deploy_branch: | |
description: Branch to deploy | |
required: false | |
default: master | |
testing: | |
description: Testing workflow | |
required: false | |
type: boolean | |
default: true | |
push: | |
paths: | |
- 'files/docker/node/release-versions/cardano-node-latest.txt' | |
- 'files/docker/node/release-versions/mithril-latest.txt' | |
jobs: | |
set_environment_vars: | |
runs-on: ubuntu-latest | |
outputs: | |
guild_deploy_branch: ${{ steps.set_guild_deploy_branch.outputs.guild_deploy_branch }} | |
g_account: ${{ steps.set_g_account.outputs.g_account }} | |
testing: ${{ steps.set_testing.outputs.testing }} | |
short_sha: ${{ steps.set_short_sha.outputs.short_sha }} | |
cnversion: ${{ steps.set_cnversion.outputs.cnversion }} | |
steps: | |
- name: Set branch name | |
id: vars | |
run: echo "branch=${GITHUB_REF#refs/heads/}" >> $GITHUB_OUTPUT | |
- name: Set GUILD_DEPLOY_BRANCH | |
id: set_guild_deploy_branch | |
run: | | |
echo "guild_deploy_branch=${{ (github.event_name == 'push' && steps.vars.outputs.branch) || github.event.inputs.guild_deploy_branch }}" >> $GITHUB_OUTPUT | |
- name: Set G_ACCOUNT | |
id: set_g_account | |
run: | | |
echo "g_account=${GITHUB_REPOSITORY_OWNER,,}" >> $GITHUB_OUTPUT | |
- name: Set TESTING | |
id: set_testing | |
run: | | |
echo "testing=${{ github.event_name == 'push' && (steps.vars.outputs.branch != 'master' || needs.set_environment_vars.outputs.guild_deploy_branch == 'docker-alpha') || github.event.inputs.testing }}" >> $GITHUB_OUTPUT | |
- uses: actions/checkout@v3 | |
with: | |
ref: ${{ steps.set_guild_deploy_branch.outputs.guild_deploy_branch }} | |
- name: Get short SHA | |
id: set_short_sha | |
run: | | |
echo "short_sha=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT | |
- name: Get CNVERSION | |
id: set_cnversion | |
run: | | |
echo "cnversion=$(cat files/docker/node/release-versions/cardano-node-latest.txt)" >> $GITHUB_OUTPUT | |
build_production: | |
needs: set_environment_vars | |
if: needs.set_environment_vars.outputs.testing == 'false' && (needs.set_environment_vars.outputs.guild_deploy_branch == 'master' || needs.set_environment_vars.outputs.guild_deploy_branch == 'docker-alpha') | |
env: | |
REGISTRY: docker.io | |
runs-on: ubuntu-latest | |
steps: | |
- name: Set IMAGE_TAGS | |
run: | | |
GUILD_DEPLOY_BRANCH=$(echo "${{ needs.set_environment_vars.outputs.guild_deploy_branch }}" | sed 's/\//_/g') | |
REGISTRY=${{ env.REGISTRY }} | |
REPO=${{ secrets.DOCKER_USER }} | |
REPO=${REPO,,} | |
IMAGE_NAME="$REGISTRY/$REPO/cardano-node" | |
CNVERSION=${{ needs.set_environment_vars.outputs.cnversion }} | |
IMAGE_TAGS="$IMAGE_NAME:latest,$IMAGE_NAME:$CNVERSION" | |
echo "IMAGE_NAME=$IMAGE_NAME" >> $GITHUB_ENV | |
echo "IMAGE_TAGS=$IMAGE_TAGS" >> $GITHUB_ENV | |
- uses: actions/checkout@v3 | |
with: | |
ref: ${{ needs.set_environment_vars.outputs.guild_deploy_branch }} | |
- name: Login to Dockerhub | |
uses: docker/login-action@v3 | |
with: | |
registry: ${{ env.REGISTRY}} | |
username: ${{ secrets.DOCKER_USER }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: Build and Push production container image | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
file: files/docker/node/dockerfile_bin | |
push: true | |
tags: ${{ env.IMAGE_TAGS }} | |
build-args: | | |
G_ACCOUNT=${{ needs.set_environment_vars.outputs.g_account }} | |
GUILD_DEPLOY_BRANCH=${{ needs.set_environment_vars.outputs.guild_deploy_branch }} | |
- name: Add summary details | |
if: always() | |
run: | | |
echo "## Summary Details" >> $GITHUB_STEP_SUMMARY | |
echo "* Image Name: ${{ env.IMAGE_NAME }}" >> $GITHUB_STEP_SUMMARY | |
echo "* Image Tags: ${{ env.IMAGE_TAGS }}" >> $GITHUB_STEP_SUMMARY | |
echo "* G_ACCOUNT: ${{ needs.set_environment_vars.outputs.g_account }}" >> $GITHUB_STEP_SUMMARY | |
echo "* GUILD_DEPLOY_BRANCH: ${{ needs.set_environment_vars.outputs.guild_deploy_branch }}" >> $GITHUB_STEP_SUMMARY | |
echo "* REGISTRY: ${{ env.REGISTRY }}" >> $GITHUB_STEP_SUMMARY | |
echo "* REGISTRY_USER: ${{ secrets.DOCKER_USER }}" >> $GITHUB_STEP_SUMMARY | |
build_testing: | |
needs: set_environment_vars | |
if: needs.set_environment_vars.outputs.testing == 'true' || needs.set_environment_vars.outputs.guild_deploy_branch != 'master' | |
env: | |
REGISTRY: ghcr.io | |
runs-on: ubuntu-latest | |
steps: | |
- name: Set IMAGE_TAGS | |
run: | | |
GUILD_DEPLOY_BRANCH=$(echo "${{ needs.set_environment_vars.outputs.guild_deploy_branch }}" | sed 's/\//_/g') | |
REGISTRY=${{ env.REGISTRY }} | |
REPO=${{ needs.set_environment_vars.outputs.g_account }} | |
IMAGE_NAME="$REGISTRY/$REPO/cardano-node" | |
CNVERSION=${{ needs.set_environment_vars.outputs.cnversion }} | |
SHA=${{ needs.set_environment_vars.outputs.short_sha }} | |
IMAGE_TAGS="$IMAGE_NAME:test,$IMAGE_NAME:$CNVERSION-$SHA,$IMAGE_NAME:$GUILD_DEPLOY_BRANCH-$SHA" | |
echo "IMAGE_NAME=$IMAGE_NAME" >> $GITHUB_ENV | |
echo "IMAGE_TAGS=$IMAGE_TAGS" >> $GITHUB_ENV | |
- uses: actions/checkout@v3 | |
with: | |
ref: ${{ needs.set_environment_vars.outputs.guild_deploy_branch }} | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ${{ env.REGISTRY}} | |
username: ${{ github.repository_owner }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build and Push testing container image | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
file: files/docker/node/dockerfile_bin | |
push: true | |
tags: ${{ env.IMAGE_TAGS }} | |
build-args: | | |
G_ACCOUNT=${{ needs.set_environment_vars.outputs.g_account }} | |
GUILD_DEPLOY_BRANCH=${{ needs.set_environment_vars.outputs.guild_deploy_branch }} | |
- name: Add summary details | |
if: always() | |
run: | | |
echo "## Summary Details" >> $GITHUB_STEP_SUMMARY | |
echo "* Image Name: ${{ env.IMAGE_NAME }}" >> $GITHUB_STEP_SUMMARY | |
echo "* Image Tags: ${{ env.IMAGE_TAGS }}" >> $GITHUB_STEP_SUMMARY | |
echo "* G_ACCOUNT: ${{ needs.set_environment_vars.outputs.g_account }}" >> $GITHUB_STEP_SUMMARY | |
echo "* GUILD_DEPLOY_BRANCH: ${{ needs.set_environment_vars.outputs.guild_deploy_branch }}" >> $GITHUB_STEP_SUMMARY | |
echo "* REGISTRY: ${{ env.REGISTRY }}" >> $GITHUB_STEP_SUMMARY | |
echo "* REGISTRY_USER: ${{ github.repository_owner }}" >> $GITHUB_STEP_SUMMARY |