Skip to content

👷 rebuild docker image. push to gcr #2

👷 rebuild docker image. push to gcr

👷 rebuild docker image. push to gcr #2

name: Docker Image CI
on:
workflow_dispatch:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
TAG: "3.1"
jobs:
main-root:
outputs:
is-main: ${{ steps.is-main-root.outputs.test }}
runs-on: ubuntu-latest
steps:
- name: Echo a message
if: github.ref == 'refs/heads/main' && github.repository == 'commonhaus/pandoc-pdf'
id: is-main-root
run: echo "test=true" >> "$GITHUB_OUTPUT"
build:
needs: main-root
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ github.repository }}
tags: |
type=raw,enable=true,priority=200,prefix=,suffix=,value=${{ env.TAG }}
- name: Log in to the Container registry
if: ${{needs.main-root.outputs.is-main}}
uses: docker/#-action@9780b0c442fbb1117ed29e0efdff1e18412f7567
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push Docker image
uses: docker/build-push-action@v6.9.0
with:
context: .
push: false
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
- name: Publish OCI image to GCR
if: ${{needs.main-root.outputs.is-main}}
id: publish-oci
run: |
image="${IMAGE_NAME}:${TAG}"
docker tag "${image}" "ghcr.io/${image}"
docker push "ghcr.io/${image}"