build-push: Add ways to extract labels #30
Workflow file for this run
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 & Push Cloudshell Images | |
on: | |
push: | |
branches: | |
- master | |
pull_request: | |
branches: | |
- master | |
env: | |
REGISTRY: ghcr.io | |
jobs: | |
build_and_push: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
packages: write | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Sanitize repo slug | |
uses: actions/github-script@v7 | |
id: repo_slug | |
with: | |
result-encoding: string | |
script: return '${{ env.REGISTRY }}/${{ github.repository }}'.toLowerCase() | |
- name: Login to GHCR | |
uses: docker/login-action@v3 | |
with: | |
registry: ${{ env.REGISTRY }} | |
username: ${{ github.actor}} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Generate Tag | |
id: tag | |
run: | | |
echo "image_tag=${{ github.sha }}-$(date '+%Y-%m-%d-%H-%M-%S')" >> $GITHUB_OUTPUT | |
- name: Extract metadata labels for base image | |
id: base-meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: ${{ env.REGISTRY }}/${{ github.repository }} | |
tags: | | |
type=raw,value=base-latest | |
type=raw,value=base-${{ steps.tag.outputs.image_tag }} | |
- name: Base image | |
uses: docker/build-push-action@v6 | |
with: | |
context: . | |
file: linux/base.Dockerfile | |
push: true | |
tags: ${{ steps.base-meta.outputs.tags }} | |
labels: ${{ steps.base-meta.outputs.labels }} | |
# - name: Extract metadata labels for tools image | |
# id: tools-meta | |
# uses: docker/metadata-action@v5 | |
# with: | |
# images: ${{ steps.repo_slug.outputs.result }}-tools | |
# - name: Tools image | |
# uses: docker/build-push-action@v6 | |
# with: | |
# context: . | |
# file: linux/tools.Dockerfile | |
# push: true | |
# tags: ${{ steps.repo_slug.outputs.result }}-tools:${{ steps.tag.outputs.image_tag }},${{ steps.repo_slug.outputs.result }}-tools:latest | |
# build-args: IMAGE_LOCATION=${{ steps.repo_slug.outputs.result }}-base:${{ steps.tag.outputs.image_tag }} | |
# labels: ${{ steps.tools-meta.outputs.labels }} |