Skip to content

Add Github registry support #10

Add Github registry support

Add Github registry support #10

Workflow file for this run

name: Publish Docker Image
on:
push:
branches: [ main ]
schedule:
- cron: '0 0 1 * *' # At 00:00 on day-of-month 1.
workflow_dispatch:
env:
DOCKER_CLI_EXPERIMENTAL: enabled
jobs:
publish:
runs-on: ubuntu-latest
timeout-minutes: 120
strategy:
matrix:
version: [16, 18, 20, lts]
permissions:
packages: write
contents: write
pull-requests: write
steps:
- name: Checkout
uses: actions/checkout@v3
with:
ref: 'main'
fetch-depth: 0
- name: Get Node Version
id: node
run: |
version="${{ matrix.version }}"
echo "Node Version $version"
if [[ "$version" == "lts" ]]; then
echo "latest=true" >> "$GITHUB_OUTPUT"
else
echo "latest=false" >> "$GITHUB_OUTPUT"
fi
- name: Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: |
${{ github.repository_owner }}/node
ghcr.io/${{ github.repository_owner }}/node
# public.ecr.aws/${{ github.repository_owner }}/node
labels: |
org.opencontainers.image.authors=${{ github.repository_owner }}
tags: |
type=raw,value=${{ matrix.version }}-alpine
flavor: |
latest=${{ steps.node.outputs.latest }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
install: true
driver-opts: image=moby/buildkit:master
- name: Login to DockerHub
uses: docker/login-action@v3
with:
logout: false
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ github.token }}
# - name: Login to Public ECR
# uses: docker/login-action@v3
# with:
# registry: public.ecr.aws
# username: ${{ secrets.AWS_ECR_ACCESS_KEY_ID }}
# password: ${{ secrets.AWS_ECR_SECRET_ACCESS_KEY }}
# env:
# AWS_REGION: us-east-1
- name: Build and push Docker images
uses: docker/build-push-action@v5
continue-on-error: true
with:
push: ${{ github.event_name != 'pull_request' }}
context: .
platforms: linux/amd64,linux/arm64/v8,linux/arm/v7,linux/arm/v6,linux/ppc64le,linux/s390x
build-args: NODE_VERSION=${{ matrix.version }}
labels: ${{ steps.meta.outputs.labels }}
tags: ${{ steps.meta.outputs.tags }}
cache-from: type=gha
cache-to: type=gha,mode=max