Build and push Docker image with custom tag #16
This file contains 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: Build and push Docker image with custom tag | |
# NOTE: this pipeline is not needed as images are pushed after release | |
on: | |
workflow_dispatch: | |
inputs: | |
tag: | |
description: 'existing git tag to be used as tag for the Docker image e.g. "custom-tag"' | |
required: true | |
default: 'my-tag' | |
include_latest: | |
description: 'should latest tag be included in the image tag' | |
required: true | |
default: 'true' | |
permissions: | |
packages: write | |
jobs: | |
push_to_ghcr: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout GitHub Action | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 # Fetch all history for all tags and branches | |
ref: ${{ github.event.inputs.tag }} | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Extract metadata | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: | | |
ghcr.io/${{ github.repository }} | |
ghcr.io/${{ github.repository }}-with-proxy | |
labels: | | |
org.opencontainers.image.title=copilot-metrics-viewer | |
org.opencontainers.image.description=Metrics viewer for GitHub Copilot usage | |
org.opencontainers.image.source=${{ github.repository }} | |
tags: | | |
type=raw,enable=true,priority=1,value=${{ github.event.inputs.tag }} | |
type=raw,enable=${{ github.event.inputs.include_latest }},priority=2,value=latest | |
type=sha | |
type=ref,event=branch | |
type=ref,event=pr | |
type=semver,pattern={{version}} | |
type=semver,pattern={{major}}.{{minor}} | |
- name: Build and push | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |
push: true |