Skip to content

token

token #4

name: Reusable workflow to build and push docker container to github container registry

Check failure on line 1 in .github/workflows/build-push-ghcr.yaml

View workflow run for this annotation

GitHub Actions / .github/workflows/build-push-ghcr.yaml

Invalid workflow file

(Line: 20, Col: 18): Unrecognized named-value: 'secrets'. Located at position 1 within expression: secrets.GITHUB_TOKEN, (Line: 40, Col: 21): Unrecognized named-value: 'input'. Located at position 1 within expression: input.token
on:
workflow_call:
inputs:
container-name:
required: true
type: string
context:
required: false
type: string
default: '.'
file:
required: false
type: string
default: 'Dockerfile'
token:
required: false
type: string
default: ${{ secrets.GITHUB_TOKEN }}
branch:
type: string
default: 'main'
jobs:
build-and-push:
runs-on: ubuntu-latest
steps:
- name: Check Out Repo
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ input.token }}
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ inputs.container-name }}
tags: |
type=ref,event=branch
type=sha
type=raw,value=${{ inputs.branch }},enable=${{ github.event_name == 'workflow_dispatch' }}
type=raw,value=latest,enable=${{ github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master' }}
- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
context: ${{ inputs.context }}
file: ${{ inputs.file }}
push: true
platforms: linux/amd64,linux/arm64
tags: ${{ steps.meta.outputs.tags }}
cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ inputs.container-name }}:buildcache
cache-to: type=registry,ref=${{ env.REGISTRY }}/${{ inputs.container-name }}:buildcache,mode=max
secrets: |
GIT_AUTH_TOKEN = ${{ secrets.GIT_AUTH_TOKEN }}
continue-on-error: true