Skip to content

build-node-images

build-node-images #108

name: Release/test puppeteer images
on:
workflow_dispatch:
inputs:
release_tag:
description: 'Tag for the images (e.g.: beta)'
required: true
apify_version:
description: 'Apify SDK version (e.g.: ^1.0.0)'
required: true
crawlee_version:
description: 'Crawlee version (e.g.: ^1.0.0)'
required: true
puppeteer_version:
description: 'Puppeteer version (e.g.: 5.5.0)'
required: true
repository_dispatch:
types: [ build-node-images ]
pull_request:
env:
RELEASE_TAG: ${{ github.event.inputs.release_tag || github.event.client_payload.release_tag || 'CI_TEST' }}
APIFY_VERSION: ${{ github.event.inputs.apify_version || github.event.client_payload.apify_version }}
CRAWLEE_VERSION: ${{ github.event.inputs.crawlee_version || github.event.client_payload.crawlee_version }}
PUPPETEER_VERSION: ${{ github.event.inputs.puppeteer_version || github.event.client_payload.puppeteer_version }}
NODE_LATEST: 18
jobs:
# Build master images that are not dependent on existing builds.
build-main:
runs-on: ubuntu-latest
strategy:
# By the time some build fails, other build can be already finished
# so fail-fast does not really prevent the publishing of all parallel builds
fail-fast: false
matrix:
image-name: [node-puppeteer-chrome]
node-version: [16, 18, 20]
steps:
-
name: Checkout
uses: actions/checkout@v3
-
name: Prepare image tags
id: prepare-tags
uses: actions/github-script@v6
env:
CURRENT_NODE: ${{ matrix.node-version }}
LATEST_NODE: ${{ env.NODE_LATEST }}
RELEASE_TAG: ${{ env.RELEASE_TAG }}
IMAGE_NAME: apify/actor-${{ matrix.image-name }}
FRAMEWORK_VERSION: ${{ env.PUPPETEER_VERSION }}
with:
script: |
const generateTags = require("./.github/scripts/prepare-node-image-tags.js");
return generateTags()
-
name: Set up QEMU
uses: docker/setup-qemu-action@v2
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
-
name: Set Dependency Versions
run: |
cd ${{ matrix.image-name }}
node ../.github/scripts/set-dependency-versions.js ${{ github.event_name == 'pull_request' }}
-
# It seems that it takes at least two minutes before a newly published version
# becomes available in the NPM registry. We wait before starting the image builds.
name: Wait For Package Registry
uses: nick-fields/retry@v2
with:
timeout_minutes: 2 # timeout for a single attempt
max_attempts: 3
retry_wait_seconds: 60 # wait between retries
command: cd ${{ matrix.image-name }} && npm i --dry-run
-
name: Build and tag image
uses: docker/build-push-action@v4
with:
context: ./${{ matrix.image-name }}
file: ./${{ matrix.image-name }}/Dockerfile
build-args: NODE_VERSION=${{ matrix.node-version }}
load: true
tags: ${{ fromJson(steps.prepare-tags.outputs.result).allTags }}
-
name: Test image
run: docker run ${{ fromJson(steps.prepare-tags.outputs.result).firstImageName }}
-
name: Login to DockerHub
if: github.event_name != 'pull_request'
uses: docker/login-action@v2
with:
username: ${{ secrets.APIFY_SERVICE_ACCOUNT_DOCKERHUB_USERNAME }}
password: ${{ secrets.APIFY_SERVICE_ACCOUNT_DOCKERHUB_TOKEN }}
-
name: Push images
if: github.event_name != 'pull_request'
run: docker push apify/actor-${{ matrix.image-name }} --all-tags