Skip to content

[EXPERIMENTAL] Reusable workflows for CI simplification #6596

[EXPERIMENTAL] Reusable workflows for CI simplification

[EXPERIMENTAL] Reusable workflows for CI simplification #6596

name: " "
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
on:
push:
branches: [main]
# Publish semver tags as releases.
tags: ['v*.*.*']
pull_request:
branches: [main]
paths-ignore:
- '**.md'
env:
# github.repository as <account>/<repo>
IMAGE_NAME: ${{ github.repository }}
jobs:
# Source the common environment
environment:
name: "image"
uses: ./.github/workflows/reusable_environment.yml
build:
name: "image / build"
timeout-minutes: ${{ fromJSON(needs.environment.outputs.LONG_TIMEOUT) }}
runs-on: ${{ needs.environment.outputs.HOST_UBUNTU_LTS }}
needs: environment
permissions:
contents: read
packages: write
steps:
- name: "Checkout"
uses: actions/checkout@v4
- name: "Set up QEMU"
uses: docker/setup-qemu-action@v3
- name: "Set up Docker Buildx"
uses: docker/setup-buildx-action@v3
# Login against a Docker registry except on PR
# https://github.com/docker/login-action
- name: "Log into registry ${{ env.REGISTRY }}"
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
registry: ${{ needs.environment.outputs.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# Extract metadata (tags, labels) for Docker
# https://github.com/docker/metadata-action
- name: "Extract Docker metadata"
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ needs.environment.outputs.REGISTRY }}/${{ env.IMAGE_NAME }}
# Build and push Docker image with Buildx (don't push on PR)
# https://github.com/docker/build-push-action
- name: "Build and push Docker image"
uses: docker/build-push-action@v6
with:
context: .
platforms: linux/amd64,linux/arm64
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}