Skip to content

Build and publish to Docker Hub #1869

Build and publish to Docker Hub

Build and publish to Docker Hub #1869

Workflow file for this run

name: Build and publish to Docker Hub
on:
pull_request:
paths-ignore:
- README.md
push:
branches:
- main
paths-ignore:
- README.md
workflow_dispatch: {}
env:
IMAGE_NAME: "shivjm/node-chromium"
jobs:
publish:
runs-on: ubuntu-latest
strategy:
matrix:
base: [alpine, debian]
node: [12, 14, 16, 17, 18, 19, 20, 22]
steps:
- uses: actions/checkout@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Get current date & time
id: get-date
run: |
echo "DATETIME=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> $GITHUB_OUTPUT
- name: Build
uses: docker/build-push-action@v4
with:
build-args: |
NODE_VERSION=${{ matrix.node }}
cache-from: type=gha
cache-to: type=gha,mode=max
file: "Dockerfile.${{ matrix.base }}"
labels: |
org.opencontainers.image.created=${{ steps.get-date.outputs.DATETIME }}
load: true
push: false
tags: "${{ env.IMAGE_NAME }}:${{ matrix.node }}"
- name: Get Chromium version
if: "github.event_name != 'pull_request'"
id: chromium-version
run: |
CHROMIUM_VERSION=$(docker run --rm -t \
$IMAGE_NAME:${{ matrix.node }} cat /etc/chromium-version \
| cut -d ' ' -f 2 | cut -d '.' -f 1)
echo "CHROMIUM_VERSION=$CHROMIUM_VERSION" >> $GITHUB_OUTPUT
- name: Log into Docker Hub
uses: docker/login-action@v2
if: "github.event_name != 'pull_request'"
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build and push
uses: docker/build-push-action@v4
if: "github.event_name != 'pull_request'"
with:
build-args: |
NODE_VERSION=${{ matrix.node }}
cache-from: type=gha
cache-to: type=gha,mode=max
file: "Dockerfile.${{ matrix.base }}"
labels: |
org.opencontainers.image.created=${{ steps.get-date.outputs.DATETIME }}
provenance: true
push: true
sbom: true
tags: "${{ env.IMAGE_NAME }}:node${{ matrix.node }}-chromium${{ steps.chromium-version.outputs.CHROMIUM_VERSION }}-${{ matrix.base }}"