Skip to content

Publish Docker images #46

Publish Docker images

Publish Docker images #46

Workflow file for this run

name: Publish Docker images
on:
workflow_dispatch:
schedule:
- cron: '0 0 * * 0'
env:
DOCKER_IMAGE_PREFIX: amazonlinux-perlbrew
jobs:
push_to_registries:
name: Push Docker image to multiple registries
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
strategy:
fail-fast: true
max-parallel: 1
matrix:
branch: ['main']
folder: ['base', 'pyenv', 'pyenv3', 'pyenv23', 'pyenv-java', 'pyenv3-java', 'pyenv23-java']
steps:
-
name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ matrix.branch }}
-
name: Set up QEMU
uses: docker/setup-qemu-action@v3
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Log in to GitHub Docker Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Sets env vars for Docker image
run: |
echo "DOCKER_IMAGE_TAG=${{env.DOCKER_IMAGE_PREFIX}}" >> $GITHUB_ENV
if: ${{ matrix.folder == 'base' }}
- name: Sets env vars for Docker image
run: |
echo "DOCKER_IMAGE_TAG=${{env.DOCKER_IMAGE_PREFIX}}-${{ matrix.folder }}" >> $GITHUB_ENV
if: ${{ matrix.folder != 'base' }}
- name: Sets env vars for Docker image
run: |
echo "DOCKER_IMAGE_BRANCH=latest" >> $GITHUB_ENV
if: ${{ matrix.branch == 'main' }}
- name: Sets env vars for Docker image
run: |
echo "DOCKER_IMAGE_BRANCH=${{ matrix.branch }}" >> $GITHUB_ENV
if: ${{ matrix.branch != 'main' }}
- name: Push Docker
uses: docker/build-push-action@v5
with:
file: ./${{ matrix.folder }}/Dockerfile
context: ./${{ matrix.folder }}
platforms: linux/amd64,linux/arm64
push: true
tags: |
${{ secrets.DOCKERHUB_ACCOUNT }}/${{env.DOCKER_IMAGE_TAG}}:${{ env.DOCKER_IMAGE_BRANCH }}
ghcr.io/${{ github.repository_owner }}/${{env.DOCKER_IMAGE_TAG}}:${{ env.DOCKER_IMAGE_BRANCH }}