Merge pull request #5 from devzero-inc/dray92-patch-1 #20
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: '[Docker] Build and Publish Runner Images' | |
on: | |
pull_request: | |
paths: | |
- "images/ubuntu/**" | |
push: | |
branches: [main] | |
paths: | |
- ".github/workflows/docker-image.yml" | |
- "images/ubuntu/**" | |
workflow_dispatch: | |
inputs: | |
release_type: | |
description: 'Release type (devel/latest)' | |
required: true | |
default: 'devel' | |
jobs: | |
build-images: | |
name: Build Ubuntu ${{ matrix.version }} | |
strategy: | |
matrix: | |
version: [22.04, 24.04] | |
runs-on: ubuntu-xl | |
permissions: | |
contents: write | |
packages: write | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set date | |
id: date | |
run: echo "date=$(date +'%Y%m%d')" >> $GITHUB_OUTPUT | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to Docker Hub | |
uses: docker/#-action@v3 | |
with: | |
username: ${{ vars.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: Build and push PR | |
if: github.event_name == 'pull_request' | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
file: images/ubuntu/dockerfiles/Dockerfile.${{ matrix.version }} | |
push: false | |
cache-from: | | |
type=registry,ref=devzeroinc/gha-runner-image-ubuntu:${{ matrix.version }}-cache | |
tags: | | |
devzeroinc/gha-runner-image-ubuntu:${{ matrix.version }}-pr-${{ github.event.pull_request.number }} | |
outputs: | | |
type=registry,oci-mediatypes=true,compression=estargz,force-compression=true | |
- name: Build and push devel | |
if: github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && github.event.inputs.release_type == 'devel') | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
file: images/ubuntu/dockerfiles/Dockerfile.${{ matrix.version }} | |
push: true | |
cache-from: | | |
type=registry,ref=devzeroinc/gha-runner-image-ubuntu:${{ matrix.version }}-cache | |
cache-to: | | |
type=registry,ref=devzeroinc/gha-runner-image-ubuntu:${{ matrix.version }}-cache,mode=max | |
tags: | | |
devzeroinc/gha-runner-image-ubuntu:${{ matrix.version }}-devel | |
devzeroinc/gha-runner-image-ubuntu:${{ matrix.version }}-devel-${{ steps.date.outputs.date }} | |
outputs: | | |
type=registry,oci-mediatypes=true,compression=estargz,force-compression=true | |
- name: Create devel release | |
if: github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && github.event.inputs.release_type == 'devel') | |
uses: softprops/action-gh-release@v1 | |
with: | |
name: Devel Release ${{ steps.date.outputs.date }} | |
tag_name: devel-${{ steps.date.outputs.date }} | |
prerelease: true | |
body: | | |
Docker images available at: | |
- devzeroinc/gha-runner-image-ubuntu:${{ matrix.version }}-devel | |
- devzeroinc/gha-runner-image-ubuntu:${{ matrix.version }}-devel-${{ steps.date.outputs.date }} | |
- name: Tag latest release | |
if: github.event_name == 'workflow_dispatch' && github.event.inputs.release_type == 'latest' | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
file: images/ubuntu/dockerfiles/Dockerfile.${{ matrix.version }} | |
push: true | |
tags: | | |
devzeroinc/gha-runner-image-ubuntu:${{ matrix.version }} | |
devzeroinc/gha-runner-image-ubuntu:${{ matrix.version }}-latest | |
outputs: | | |
type=registry,oci-mediatypes=true,compression=estargz,force-compression=true | |
- name: Create latest release | |
if: github.event_name == 'workflow_dispatch' && github.event.inputs.release_type == 'latest' | |
uses: softprops/action-gh-release@v1 | |
with: | |
name: Latest Release ${{ steps.date.outputs.date }} | |
tag_name: latest-${{ steps.date.outputs.date }} | |
prerelease: false | |
body: | | |
Docker images available at: | |
- devzeroinc/gha-runner-image-ubuntu:${{ matrix.version }} | |
- devzeroinc/gha-runner-image-ubuntu:${{ matrix.version }}-latest | |
- name: Setup tmate session | |
uses: mxschmitt/action-tmate@v3 | |
if: ${{ failure() }} | |
timeout-minutes: 15 |