Cache linux/amd64 Docker Image for ubuntu:jammy #129
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: Cache Docker Image | |
on: | |
workflow_dispatch: | |
inputs: | |
image_name: | |
description: 'Docker image name' | |
default: 'alpine' | |
required: true | |
version: | |
description: 'Docker image version' | |
default: 'latest' | |
required: true | |
architecture: | |
description: 'Docker image architecture' | |
default: 'linux/arm64' | |
required: true | |
# schedule: | |
# - cron: '0 23 * * *' | |
run-name: Cache ${{ github.event.inputs.architecture }} Docker Image for ${{ github.event.inputs.image_name }}:${{ github.event.inputs.version }} | |
# concurrency: | |
# group: ${{ github.workflow }}-${{ github.ref }} | |
# cancel-in-progress: true | |
jobs: | |
update_cache: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Set input parameters | |
id: params | |
run: | | |
echo "IMAGE_NAME=${{ github.event.inputs.image_name }}" >> $GITHUB_ENV | |
echo "VERSION=${{ github.event.inputs.version }}" >> $GITHUB_ENV | |
echo "ARCHITECTURE=${{ github.event.inputs.architecture }}" >> $GITHUB_ENV | |
- name: Pull Docker image | |
run: | | |
docker pull --platform $ARCHITECTURE $IMAGE_NAME:$VERSION | |
- name: Save Docker image | |
run: | | |
SHA512=$(echo -n "$IMAGE_NAME:$VERSION-$ARCHITECTURE" | sha512sum | awk '{print $1}') | |
echo "SHA512=${SHA512}" >> $GITHUB_ENV | |
docker save $IMAGE_NAME:$VERSION -o ${SHA512}.tar | |
- name: compress Docker image | |
run: | | |
tar -cJf ${SHA512}.tar.xz ${SHA512}.tar | |
rm ${SHA512}.tar | |
echo "Compressed to ${SHA512}.tar.xz" | |
- name: Upload to Release | |
uses: ncipollo/release-action@main | |
with: | |
tag: mirror | |
artifacts: "*.tar.xz" | |
allowUpdates: true | |
removeArtifacts: false | |
replacesArtifacts: true | |
makeLatest: false | |
token: ${{ secrets.GITHUB_TOKEN }} | |
body: | | |
Docker images cache mirror. don't forget to enable longpath. git config --global core.longpaths true | |
https://github.com/feicong/ebpf-course |