-
Notifications
You must be signed in to change notification settings - Fork 87
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
allow to run docker ci manually by entering a branch name
date time will be used so multiple images can be built and publish per branch.
- Loading branch information
Showing
1 changed file
with
80 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
# This workflow builds docker images on given custom 'branch name'. | ||
name: Custom Docker | ||
|
||
# Limit concurrent runs of this workflow within a single PR | ||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} | ||
cancel-in-progress: true | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
branch_name: | ||
type: string | ||
description: 'Used to publish a hydra-node-{datetime}-{branch_name} docker image' | ||
required: true | ||
default: "master" | ||
|
||
permissions: | ||
packages: write | ||
|
||
jobs: | ||
docker: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: 📥 Checkout repository | ||
uses: actions/checkout@v4 | ||
with: | ||
ref: ${{ github.event.inputs.branch_name }} | ||
|
||
- name: 🐳 Login to GitHub Container Registry | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: ❄ Prepare nix | ||
uses: cachix/install-nix-action@v30 | ||
with: | ||
extra_nix_config: | | ||
accept-flake-config = true | ||
log-lines = 1000 | ||
- name: ❄ Cachix cache of nix derivations | ||
uses: cachix/cachix-action@v15 | ||
with: | ||
name: cardano-scaling | ||
authToken: '${{ secrets.CACHIX_CARDANO_SCALING_AUTH_TOKEN }}' | ||
|
||
- name: 🔨 Build image using nix | ||
run: | | ||
IMAGE_NAME=ghcr.io/${{github.repository_owner}}/hydra-node | ||
echo "IMAGE_NAME=${IMAGE_NAME}" >> $GITHUB_ENV | ||
nix build .#docker-hydra-node | ||
./result | docker load | ||
VERSION_NAME=${{github.ref_name}} | ||
BRANCH_NAME="${{ github.event.inputs.branch_name }}" | ||
[[ -z "${BRANCH_NAME}" ]] && { echo "branch_name is required"; exit 1; } | ||
DATETIME=$(date '+%Y%m%d%H%M') | ||
CUSTOM_TAG="${DATETIME}-${BRANCH_NAME}" | ||
echo "CUSTOM_TAG=${CUSTOM_TAG}" >> $GITHUB_ENV | ||
# Use 'FROM' instruction to use docker build with --label | ||
echo "FROM hydra-node" | docker build \ | ||
--label org.opencontainers.image.source=https://github.com/cardano-scaling/hydra \ | ||
--label org.opencontainers.image.licenses=Apache-2.0 \ | ||
--label org.opencontainers.image.created=$(date -Is) \ | ||
--label org.opencontainers.image.revision=${{github.sha}} \ | ||
--label org.opencontainers.image.version=${VERSION_NAME:-unstable} \ | ||
--tag ${IMAGE_NAME}:${CUSTOM_TAG} - | ||
docker images | ||
docker inspect ${IMAGE_NAME}:${CUSTOM_TAG} | ||
- name: 📤 Push to registry | ||
run: | | ||
docker push "${IMAGE_NAME}:${CUSTOM_TAG}" |