OCI Base Image #511
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
# https://github.com/marketplace/actions/build-and-push-docker-images | |
name: OCI Base Image | |
on: | |
schedule: | |
- cron: '0 3 * * *' | |
workflow_dispatch: | |
jobs: | |
build-publish: | |
runs-on: ubuntu-20.04 | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Set up QEMU | |
id: qemu | |
uses: docker/setup-qemu-action@v3 | |
with: | |
image: tonistiigi/binfmt:latest | |
platforms: linux/amd64,linux/arm64 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Available platforms | |
run: echo ${{ steps.buildx.outputs.platforms }} | |
- name: Cache Docker layers | |
uses: actions/[email protected] | |
with: | |
path: /tmp/.buildx-cache | |
key: ${{ runner.os }}-${{ matrix.image_tag_suffix }}-buildx-${{ github.event.pull_request.head.sha || github.sha }} | |
restore-keys: | | |
${{ runner.os }}-${{ matrix.image_tag_suffix }}-buildx- | |
- name: Check for Push Credentials | |
id: authorized | |
run: | | |
if [ -n "${{ secrets.DOCKERHUB_USERNAME }}" ]; then | |
echo "PUSH=true" >> $GITHUB_OUTPUT | |
else | |
echo "PUSH=false" >> $GITHUB_OUTPUT | |
fi | |
- name: Login to DockerHub | |
if: steps.authorized.outputs.PUSH == 'true' | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_PASSWORD }} | |
- name: Build and push | |
uses: docker/build-push-action@v5 | |
with: | |
context: packaging/base-image | |
platforms: linux/amd64,linux/arm64 | |
pull: true | |
push: ${{ steps.authorized.outputs.PUSH }} | |
tags: | | |
pivotalrabbitmq/ubuntu:20.04 | |
cache-from: type=local,src=/tmp/.buildx-cache | |
cache-to: type=local,dest=/tmp/.buildx-cache-new | |
# Temp fix | |
# https://github.com/docker/build-push-action/issues/252 | |
# https://github.com/moby/buildkit/issues/1896 | |
- name: Move cache | |
run: | | |
rm -rf /tmp/.buildx-cache | |
mv /tmp/.buildx-cache-new /tmp/.buildx-cache |