Create and publish a Docker image #51
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: Create and publish a Docker image | |
on: | |
workflow_dispatch: | |
push: | |
branches: | |
- main | |
paths: | |
- VERSION | |
- 'docker/**' | |
env: | |
REGISTRY: ghcr.io | |
IMAGE_NAME: ${{ github.repository }} | |
jobs: | |
build-and-push-image: | |
strategy: | |
matrix: | |
path: [docker, actions-runner-controller, arc-container-dind] | |
environment: publish | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
packages: write | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Output Collector | |
id: output-collector | |
uses: collinmcneese/file-output-collector@main | |
with: | |
file: "./VERSION" | |
- name: Prep | |
run: | | |
echo Building with Runner version ${{ steps.output-collector.outputs.output }} | |
echo ${{ steps.output-collector.outputs.output }} | grep 2 | |
- name: Log in to the Container registry | |
uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d | |
with: | |
registry: ${{ env.REGISTRY }} | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Extract metadata (tags, labels) for ${{ matrix.path }} | |
if: ${{ matrix.path == 'docker' }} | |
id: meta-docker | |
uses: docker/metadata-action@8e5442c4ef9f78752691e2d8f8d19755c6f78e81 | |
with: | |
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | |
- name: Extract metadata (tags, labels) for ${{ matrix.path }} | |
if: ${{ matrix.path == 'actions-runner-controller' }} | |
id: meta-arc | |
uses: docker/metadata-action@8e5442c4ef9f78752691e2d8f8d19755c6f78e81 | |
with: | |
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | |
- name: Build and Push Docker image for ${{ matrix.path }} | |
if: ${{ matrix.path == 'docker' }} | |
uses: docker/build-push-action@af5a7ed5ba88268d5278f7203fb52cd833f66d6e | |
with: | |
context: ./docker | |
push: true | |
labels: ${{ steps.meta-docker.outputs.labels }} | |
build-args: | | |
RUNNER_VERSION=${{ steps.output-collector.outputs.output }} | |
tags: | | |
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest | |
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.output-collector.outputs.output }} | |
- name: Build and Push Docker image for ${{ matrix.path }} | |
if: ${{ matrix.path == 'actions-runner-controller' }} | |
uses: docker/build-push-action@af5a7ed5ba88268d5278f7203fb52cd833f66d6e | |
with: | |
context: ./actions-runner-controller | |
push: true | |
labels: ${{ steps.meta-arc.outputs.labels }} | |
build-args: | | |
RUNNER_VERSION=${{ steps.output-collector.outputs.output }} | |
tags: | | |
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-arc:latest | |
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-arc:${{ steps.output-collector.outputs.output }} | |
- name: Build and Push Docker image for ${{ matrix.path }} | |
if: ${{ matrix.path == 'arc-container-dind' }} | |
uses: docker/build-push-action@af5a7ed5ba88268d5278f7203fb52cd833f66d6e | |
with: | |
context: ./arc-container-dind | |
push: true | |
labels: ${{ steps.meta-arc.outputs.labels }} | |
build-args: | | |
RUNNER_VERSION=${{ steps.output-collector.outputs.output }} | |
tags: | | |
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-arc-container-dind:latest | |
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-arc-container-dind:${{ steps.output-collector.outputs.output }} |