feat: add initial nilchain-devnet docker image #1
Workflow file for this run
This file contains hidden or 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: Build and push docker image | |
on: | |
pull_request: | |
# workflow_dispatch: | |
env: | |
REGISTRY: ghcr.io | |
IMAGE_NAME: nilchain-devnet | |
jobs: | |
docker-build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Extract metadata (tags, labels) for Docker | |
id: meta | |
uses: docker/metadata-action@v4 | |
with: | |
images: ${{ env.REGISTRY }}/NillionNetwork/${{ env.IMAGE_NAME }} | |
tags: | | |
type=ref,event=branch | |
type=ref,event=tag | |
flavor: | | |
latest=false # Ensure 'latest' tag is not generated | |
- name: Set VERSION environment variable | |
run: | | |
# Extract the first tag from the generated tags | |
TAG=$(echo ${{ steps.meta.outputs.tags }} | cut -d ',' -f 1) | |
TAG=$(echo $TAG | cut -d ':' -f 2) | |
echo "VERSION=$TAG" >> $GITHUB_ENV | |
- name: Build Docker image | |
uses: docker/build-push-action@v2 | |
with: | |
context: . | |
tags: ${{ steps.meta.outputs.tags }} | |
build-args: | | |
VERSION=${{ env.VERSION }} | |
- name: Debug tags | |
run: | | |
echo "Generated tags: ${{ steps.meta.outputs.tags }}" | |
echo "Generated labels: ${{ steps.meta.outputs.labels }}" | |
- name: List Docker images | |
run: docker images | |
- name: Test image is runnable | |
run: | | |
# Extract the tag from the current context | |
TAG=$(echo ${{ steps.meta.outputs.tags }} | cut -d ',' -f 1) | |
echo "Running Docker container with tag: $TAG" | |
docker run --rm $TAG version | |
- name: Log in to the Container registry | |
uses: docker/login-action@v2 | |
with: | |
registry: ${{ env.REGISTRY }} | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Push Docker image | |
uses: docker/build-push-action@v2 | |
with: | |
context: . | |
push: true | |
tags: ${{ steps.meta.outputs.tags }} | |
build-args: | | |
VERSION=${{ env.VERSION }} |