Skip to content

Update node-build-artifact.yml #3

Update node-build-artifact.yml

Update node-build-artifact.yml #3

name: Build and Publish Docker Image
on:
workflow_dispatch:
workflow_call:
secrets:
GITHUB_TOKEN:

Check failure on line 7 in .github/workflows/docker-build-and-publish.yml

View workflow run for this annotation

GitHub Actions / .github/workflows/docker-build-and-publish.yml

Invalid workflow file

secret name `GITHUB_TOKEN` within `workflow_call` can not be used since it would collide with system reserved name
required: true
jobs:
# define job to build and publish docker image
build-and-publish:
name: Build and Publish Docker image
# run only when code is compiling and tests are passing
runs-on: ubuntu-latest
# steps to perform in job
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Docker metadata
id: meta
uses: docker/metadata-action@v4
with:
# list of Docker images to use as base name for tags
images: |
ghcr.io/${{ github.repository }}
# generate Docker tags based on the following events/attributes
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=sha
type=raw,value=latest,enable={{is_default_branch}}
# setup Docker buld action
- name: Set up Docker Buildx
id: docker_build
uses: docker/setup-buildx-action@v2
# - name: Login to DockerHub
# uses: docker/login-action@v2
# with:
# username: ${{ secrets.DOCKERHUB_USERNAME }}
# password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Login to Github Packages
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and Publish to GitHub Container Registry
uses: docker/build-push-action@v4
with:
context: .
platforms: linux/amd64,linux/arm64
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
VERSION=${{ github.event.release.tag_name }}
RELEASE_TIME=${{ github.event.release.created_at }}
GIT_REPO=${{ github.repository }}
GIT_COMMIT_SHA=${{ github.sha }}
GIT_COMMIT_TIME=${{ github.event.push.head_commit.timestamp }}
GIT_REF=${{ github.ref_name }}
GIT_WORKFLOW_SHA=${{ github.workflow_sha }}
cache-from: type=registry,ref=${{ github.ref_name }}
cache-to: type=inline
- name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }}