Skip to content

ci: update rust in docker publish (#827) #22

ci: update rust in docker publish (#827)

ci: update rust in docker publish (#827) #22

name: CI for tags
on:
push:
tags:
- "v*"
env:
DOCKERFILE: scripts/ci/dockerfiles/polkadot-introspector_injected.Dockerfile
CI_IMAGE: paritytech/ci-unified:bullseye-1.81.0
IMAGE_NAME: paritytech/polkadot-introspector
jobs:
set-image:
# GitHub Actions does not allow using 'env' in a container context.
# This workaround sets the container image for each job using 'set-image' job output.
runs-on: ubuntu-latest
outputs:
CI_IMAGE: ${{ steps.set_image.outputs.CI_IMAGE }}
steps:
- id: set_image
run: echo "CI_IMAGE=${{ env.CI_IMAGE }}" >> $GITHUB_OUTPUT
# build
build:
runs-on: ubuntu-latest
needs: [set-image]
container:
image: ${{ needs.set-image.outputs.CI_IMAGE }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Cache
uses: Swatinem/rust-cache@v2
with:
cache-on-failure: true
- name: Build
run: |
time cargo build --release
- name: Archive artifacts
uses: actions/upload-artifact@v4
with:
name: polkadot-introspector
path: |
target/release/polkadot-block-time
target/release/polkadot-jaeger
target/release/polkadot-kvdb
target/release/polkadot-parachain-tracer
target/release/polkadot-whois
retention-days: 1
# build/publish docker image
build-publish-docker:
runs-on: ubuntu-latest
needs: [set-image, build]
environment: tags
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set image tag for Docker image
run: |
echo "PUSH_IMAGE=true" >> $GITHUB_ENV
echo "IMAGE_TAG=${{ github.ref_name }}" >> $GITHUB_ENV
- name: Download artifacts
uses: actions/download-artifact@v4
with:
name: polkadot-introspector
path: ./artifacts
- name: Set permissions
run: |
chmod +x ./artifacts/*
- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build/Push Docker image
uses: docker/build-push-action@v6
with:
push: true
context: .
file: ${{ env.DOCKERFILE }}
build-args: |
VCS_REF="${{ github.sha }}"
build-arg BUILD_DATE="$(date -u '+%Y-%m-%dT%H:%M:%SZ')"
tags: |
${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }}
${{ env.IMAGE_NAME }}:latest