Skip to content

Update latest CI image #102

Update latest CI image

Update latest CI image #102

name: update_CI_image
run-name: Update latest CI image
on:
pull_request_target: # A.K.A. This is a privileged action. See `pull_request`.
types:
- closed # CAUTION: Includes un-merged PR's.
branches:
- develop
workflow_dispatch:
# Requires write access to trigger.
inputs:
pull_from_cache:
description: Build image with 'latest' cache
required: false
default: true
type: boolean
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
packages: write
jobs:
update_AIS_CI_image:
env:
AIS_DOCKER_REGISTRY: ghcr.io/rocm/hipfile
AIS_CI_IMAGE_NAME: ais_ci_${{ matrix.supported_platforms }}
if: ${{ github.event.pull_request.merged == true || github.event_name == 'workflow_dispatch' }}
runs-on: [ubuntu-24.04]
container: docker:28.5
strategy:
matrix:
supported_platforms:
- rocky
- suse
- ubuntu
steps:
- name: Fetching code repository...
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 #v6.0.1
- name: Authenticating to GitHub Container Registry.
uses: docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef #v3.6.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set target AIS CI Image
id: ci-image
run: |
echo "AIS_CI_IMAGE=${{ env.AIS_DOCKER_REGISTRY }}/${{ env.AIS_CI_IMAGE_NAME}}:latest" \
>> "${GITHUB_OUTPUT}"
- name: Set Docker Cache Instruction
id: use-cache
# If triggered by a pull_request, pull_from_cache will be null. Note
# however `false == null` resolves to `true`. Use empty string to check
# for 'null'.
# See: https://docs.github.com/en/actions/reference/workflows-and-actions/expressions
# for how null gets converted when compared to non-null, and converted into a string.
run: >-
echo "CACHE_FROM_CMD=${{
( format('{0}', inputs.pull_from_cache) == '' || inputs.pull_from_cache ) &&
format('--cache-from=type=registry,ref=\"{0}-cache\"', steps.ci-image.outputs.AIS_CI_IMAGE) ||
''
}}" >> "${GITHUB_OUTPUT}"
- name: Setup Docker Builder
uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f #v3.12.0
with:
name: ais-builder
driver: docker-container
cache-binary: false # True uses the GHA Cache Backend.
- name: Build & Push latest image for AIS CI
run: |
docker buildx build \
-f ${GITHUB_WORKSPACE}/util/docker/DOCKERFILE.${{ env.AIS_CI_IMAGE_NAME }} \
--label "org.opencontainers.image.description= \
Latest AIS CI Image for ${{ matrix.supported_platforms }}." \
--cache-to=type=registry,ref="${{ steps.ci-image.outputs.AIS_CI_IMAGE }}-cache" \
${{ steps.use-cache.outputs.CACHE_FROM_CMD }} \
--push \
-t ${{ steps.ci-image.outputs.AIS_CI_IMAGE }} \
${GITHUB_WORKSPACE}