Skip to content

feature(ci): Run docker build on all pushes #41

feature(ci): Run docker build on all pushes

feature(ci): Run docker build on all pushes #41

Workflow file for this run

name: Push Image to ghcr.io
on:
release:
types:
- published
push: {}
pull_request: {}
workflow_dispatch: {}
schedule:
# Everyday at 4:00 AM UTC
- cron: "0 4 * * *"
env:
REGISTRY: ghcr.io
GH_TOKEN: ${{ github.token }}
jobs:
build:
name: "Build image"
runs-on: ubuntu-latest
steps:
- name: Install Nix with good defaults
uses: input-output-hk/install-nix-action@v21
with:
extra_nix_config: |
trusted-public-keys = cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY= hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ=
substituters = https://cache.iog.io/ https://cache.nixos.org/
experimental-features = nix-command flakes fetch-closure
allow-import-from-derivation = true
accept-flake-config = true
nix_path: nixpkgs=channel:nixos-unstable
# cardano-parts requires nix >= 2.17.0; We can remove this after the next release
# to install-nix-action (v23)
install_url: https://releases.nixos.org/nix/nix-2.17.0/install
- name: Checkout repository
uses: actions/checkout@v3
- name: Log in to ghcr.io
uses: docker/#-action@v2.1.0
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set environment variables
run: |
# Downcase the package repository, because docker reference
# are required to be lower case
REPO_OWNER="$(echo ${{ github.repository_owner }} | tr '[:upper:]' '[:lower:]')"
IMAGE_TAG="$(echo $GITHUB_REF_NAME | tr '/' '_')"
echo "REPO_OWNER=${REPO_OWNER}" >> "$GITHUB_ENV"
echo "IMAGE_TAG=${IMAGE_TAG}" >> "$GITHUB_ENV"
- name: Wait for Hydra
uses: input-output-hk/actions/wait-for-hydra@latest
with:
check: ci/hydra-build:x86_64-linux.required
- name: Load images
run: |
# Download the images from the nix binary cachhe
nix build \
--builders "" \
--max-jobs 0 \
--out-link result-cardano-db-sync \
.#cardano-db-sync-docker
nix build \
--builders "" \
--max-jobs 0 \
--out-link result-cardano-smash-server
.#cardano-smash-server-docker
- name: Upload ${{ github.actor }}/cardano-db-sync
if: ${{ github.ref_type == 'tags' || github.event_name == 'release' }}
run: |
# Push the image
skopeo copy \
docker-archive:./result-cardano-db-sync \
docker://ghcr.io/${REPO_OWNER}/cardano-db-sync:$IMAGE_TAG
# Also tag it as latest
skopeo copy \
docker-archive:./result-cardano-db-sync \
docker://ghcr.io/${REPO_OWNER}/cardano-db-sync:latest
- name: Upload ${{ github.actor }}/cardano-smash-server
if: ${{ github.ref_type == 'tags' || github.event_name == 'release' }}
run: |
# Push the image
skopeo copy \
docker-archive:./result-cardano-smash-server \
docker://ghcr.io/${REPO_OWNER}/cardano-smash-server:$IMAGE_TAG
# Also tag it as latest
skopeo copy \
docker-archive:./result-cardano-smash-server \
docker://ghcr.io/${REPO_OWNER}/cardano-smash-server:latest