Release/test bun-node puppeteer images #59
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
name: Release/test bun-node puppeteer images | |
on: | |
# TODO: If you @apify employees are reading this, please update it | |
schedule: | |
# It's 1 hour after bun-node normally start building | |
# Every day at 01:00 UTC | |
- cron: "0 1 * * *" | |
workflow_dispatch: | |
inputs: | |
release_tag: | |
description: "Tag for the images (e.g.: beta)" | |
required: false | |
apify_version: | |
description: "Apify SDK version (e.g.: ^1.0.0)" | |
required: false | |
crawlee_version: | |
description: "Crawlee version (e.g.: ^1.0.0)" | |
required: false | |
puppeteer_version: | |
description: "Puppeteer version (e.g.: 5.5.0)" | |
required: false | |
is_latest_browser_image: | |
description: If this is a release of the latest browser image. This gets autofilled by CI in crawlee | |
type: boolean | |
default: false | |
repository_dispatch: | |
types: | |
- build-bun-node-images | |
- build-bun-node-images-puppeteer | |
- build-node-images | |
- build-node-images-puppeteer | |
pull_request: | |
env: | |
RELEASE_TAG: ${{ github.event.inputs.release_tag || github.event.client_payload.release_tag || 'latest' }} | |
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 }} | |
IS_LATEST_BROWSER_IMAGE: ${{ github.event.inputs.is_latest_browser_image || github.event.client_payload.is_latest_browser_image || false }} | |
BUN_LATEST: 1 | |
NODE_LATEST: 20 | |
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: [bun-node-puppeteer-chrome] | |
node-version: [18, 20, 22] | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Prepare image tags | |
id: prepare-tags | |
uses: actions/github-script@v7 | |
env: | |
CURRENT_NODE: ${{ matrix.node-version }} | |
LATEST_BUN: ${{ env.BUN_LATEST }} | |
LATEST_NODE: ${{ env.NODE_LATEST }} | |
RELEASE_TAG: ${{ env.RELEASE_TAG }} | |
# TODO: If you @apify employees are reading this, please update it | |
IMAGE_NAME: imbios/actor-${{ matrix.image-name }} | |
FRAMEWORK_VERSION: ${{ env.PUPPETEER_VERSION }} | |
IS_LATEST_BROWSER_IMAGE: ${{ env.IS_LATEST_BROWSER_IMAGE }} | |
with: | |
script: | | |
const generateTags = require("./.github/scripts/prepare-bun-node-image-tags.js"); | |
return generateTags(); | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- 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@v3 | |
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: Set APIFY_VERSION | |
# Only run if the input is not set | |
if: github.event.inputs.apify_version == null | |
run: echo "APIFY_VERSION=$(npm view apify version)" >> $GITHUB_ENV | |
- name: Set CRAWLEE_VERSION | |
# Only run if the input is not set | |
if: github.event.inputs.crawlee_version == null | |
run: echo "CRAWLEE_VERSION=$(npm view crawlee version)" >> $GITHUB_ENV | |
- name: Set PUPPETEER_VERSION | |
# Only run if the input is not set | |
if: github.event.inputs.puppeteer_version == null | |
run: echo "PUPPETEER_VERSION=$(npm view puppeteer version)" >> $GITHUB_ENV | |
- name: Build and tag image | |
uses: docker/build-push-action@v5 | |
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@v3 | |
with: | |
username: ${{ secrets.APIFY_SERVICE_ACCOUNT_DOCKERHUB_USERNAME }} | |
password: ${{ secrets.APIFY_SERVICE_ACCOUNT_DOCKERHUB_TOKEN }} | |
- name: Push images | |
if: github.event_name != 'pull_request' | |
# TODO: If you @apify employees are reading this, please update it | |
run: docker push imbios/actor-${{ matrix.image-name }} --all-tags |