diff --git a/.github/workflows/services-base.yml b/.github/workflows/services-base.yml index 42a1c1ae6..16043630d 100644 --- a/.github/workflows/services-base.yml +++ b/.github/workflows/services-base.yml @@ -14,7 +14,7 @@ on: env: REGISTRY: ghcr.io - IMAGE_NAME: blockscout/eth-bytecode-db + IMAGE_NAME: blockscout/services-base jobs: check_tag: @@ -66,17 +66,15 @@ jobs: - name: Check image tag exists id: check_existence env: -# TAG: ${{ steps.get_image_tag.outputs.tag }} - TAG: v0.2.0 + TAG: ${{ steps.get_image_tag.outputs.tag }} run: | TOKEN=$(echo ${{ secrets.GITHUB_TOKEN }} | base64) - EXISTING_TAGS=$(curl -H "Authorization: Bearer ${TOKEN}" https://ghcr.io/v2/blockscout/visualizer/tags/list) + EXISTING_TAGS=$(curl -H "Authorization: Bearer ${TOKEN}" https://ghcr.io/v2/${IMAGE_NAME}/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 "There is already a pushed image with ${TAG} as tag. Skipping." echo "is_new=false" >> $GITHUB_OUTPUT else - echo "TAG $TAG does not exist in the tags array." echo "is_new=true" >> $GITHUB_OUTPUT fi @@ -87,34 +85,36 @@ jobs: 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: Checkout + uses: actions/checkout@v4 + + - 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 }} + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 -# - 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 }}" -# + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - name: Build and push + uses: docker/build-push-action@v5 + with: + context: "docker" + file: "docker/base.Dockerfile" + push: ${{ github.ref == 'refs/heads/main' }} + tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ needs.check_tag.outputs.tag }} , ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest + platforms: | + linux/amd64 + linux/arm64/v8 + labels: ${{ steps.meta.outputs.labels }}