This file contains hidden or 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: Reusable workflow to build and push docker container to github container registry | ||
|
Check failure on line 1 in .github/workflows/build-push-ghcr.yaml
|
||
| 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 | ||