Unify protoc dependencies between services #26
Workflow file for this run
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
on: | |
push: | |
branches: | |
- 'main' | |
paths: | |
- .github/workflows/base-image.yml | |
- docker/base.Dockerfile | |
pull_request: | |
paths: | |
- .github/workflows/base-image.yml | |
- docker/base.Dockerfile | |
env: | |
REGISTRY: ghcr.io | |
IMAGE_NAME: blockscout/eth-bytecode-db | |
jobs: | |
check_tag: | |
name: Check tag existence | |
runs-on: ubuntu-latest | |
outputs: | |
tag: ${{ steps.get_image_tag.outputs.tag }} | |
is_new: ${{ steps.check_existence.outputs.is_new }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Get image tag | |
id: get_image_tag | |
env: | |
DOCKERFILE_PATH: "docker/base.Dockerfile" | |
run: | | |
CONTENT=$(cat $DOCKERFILE_PATH) | |
nl=$'\n' | |
if [[ $CONTENT =~ ARG\ CARGO_CHEF_VERSION=([^$nl]+) ]]; then | |
CARGO_CHEF_TAG=${BASH_REMATCH[1]} | |
else | |
echo "Failed to extract CARGO_CHEF_TAG from Dockerfile" | |
exit 1 | |
fi | |
if [[ $CONTENT =~ ARG\ PROTOC_VERSION=([^$nl]+) ]]; then | |
PROTOC_VERSION=${BASH_REMATCH[1]} | |
else | |
echo "Failed to extract PROTOC_VERSION from Dockerfile" | |
exit 1 | |
fi | |
if [[ $CONTENT =~ ARG\ PROTOC_GEN_OPENAPIV2_VERSION=([^$nl]+) ]]; then | |
PROTOC_GEN_OPENAPIV2_VERSION=${BASH_REMATCH[1]} | |
else | |
echo "Failed to extract PROTOC_GEN_OPENAPIV2_VERSION from Dockerfile" | |
exit 1 | |
fi | |
TAG=chef-${CARGO_CHEF_TAG}-protoc-${PROTOC_VERSION}-openapi-${PROTOC_GEN_OPENAPIV2_VERSION} | |
echo "TAG=$TAG" | |
# Save values to be available from the next steps | |
echo "tag=$TAG" >> $GITHUB_OUTPUT | |
- name: Check image tag exists | |
id: check_existence | |
env: | |
# TAG: ${{ steps.get_image_tag.outputs.tag }} | |
TAG: v0.2.0 | |
run: | | |
TOKEN=$(echo ${{ secrets.GITHUB_TOKEN }} | base64) | |
EXISTING_TAGS=$(curl -H "Authorization: Bearer ${TOKEN}" https://ghcr.io/v2/blockscout/visualizer/tags/list) | |
if echo "${EXISTING_TAGS}" | jq -e ".tags | map(select(. == \"$TAG\")) | length > 0" > /dev/null; then | |
echo "TAG $TAG exists in the tags array." | |
echo "is_new=false" >> $GITHUB_OUTPUT | |
else | |
echo "TAG $TAG does not exist in the tags array." | |
echo "is_new=true" >> $GITHUB_OUTPUT | |
fi | |
build_and_push: | |
name: Build and push | |
needs: | |
- check_tag | |
if: | | |
${{ needs.check_tag.outputs.is_new == 'true' }} | |
runs-on: ubuntu-latest | |
steps: | |
- name: Tag exists | |
run: | | |
echo "tag_exists=${{ needs.check_tag.outputs.is_new }}" | |
# - name: Checkout | |
# uses: actions/checkout@v4 | |
# | |
# - name: Set up QEMU | |
# uses: docker/setup-qemu-action@v3 | |
# | |
# - name: Set up Docker Buildx | |
# uses: docker/setup-buildx-action@v3 | |
# | |
# - name: Login to GitHub Container Registry | |
# uses: docker/login-action@v2 | |
# with: | |
# registry: ${{ env.REGISTRY }} | |
# username: ${{ github.actor }} | |
# password: ${{ secrets.GITHUB_TOKEN }} | |
# - name: Extract metadata for Docker | |
# id: meta | |
# uses: docker/metadata-action@v5 | |
# with: | |
# images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest | |
# | |
# - name: Print docker tags | |
# run: | | |
# echo "tags=${{ steps.meta.outputs.tags }}" | |
# echo "labels=${{ steps.meta.outputs.labels }}" | |
# | |