Skip to content

refactoring setup

refactoring setup #4

Workflow file for this run

name: Infralovers Container Build - dapr-distributed-calendar
on:
push:
branches: [ 'main' ]
paths: [ 'dapr-distributed-calendar/**' ]
pull_request:
branches: [ 'main' ]
paths: [ 'dapr-distributed-calendar/**' ]
env:
platforms: linux/amd64
jobs:
build:
strategy:
fail-fast: false
matrix:
container: [ go, node, python ]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Prepare tagging
id: prep
run: |
IMAGE_NAME=$(basename ${{ github.repository }})
IMAGE_REPO=${{ github.repository_owner }}
if [[ -n "${{ secrets.IMAGE_NAME }}" ]]; then
IMAGE_NAME="${{ secrets.IMAGE_NAME }}"
fi
if [[ -n "${{ secrets.IMAGE_REPO }}" ]]; then
IMAGE_REPO="${{ secrets.IMAGE_REPO }}"
fi
QUAY_IMAGE="quay.io/$IMAGE_REPO/$IMAGE_NAME/${{ matrix.container }}"
GHCR_IMAGE="ghcr.io/${{ github.repository }}/${{ matrix.container }}"
VERSION="dev"
if [[ '${{ needs.prebuild.outputs.version }}' != '' ]]; then
VERSION="${{ needs.prebuild.outputs.version }}"
fi
if [ "${{ github.event_name }}" = "schedule" ]; then
VERSION="nightly"
fi
TAGS="${QUAY_IMAGE}:${VERSION},${GHCR_IMAGE}:${VERSION}"
if [[ $VERSION =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then
TAGS="$TAGS,${QUAY_IMAGE}:latest,${GHCR_IMAGE}:latest"
fi
echo "settings tag ${TAGS}"
echo "tags=${TAGS}" >> $GITHUB_OUTPUT
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v2
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
with:
platforms: ${{ env.platforms }}
- name: Cache Docker layers
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}-${{ matrix.container }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Login to Quay
if: needs.prebuild.outputs.version != ''
uses: docker/login-action@v1
with:
registry: quay.io
username: ${{ secrets.QUAY_USER }}
password: ${{ secrets.QUAY_TOKEN }}
- name: Login to GitHub Container Registry
if: needs.prebuild.outputs.version != ''
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.BOT_ACCESS_TOKEN }}
- name: Build and push
id: docker_build
uses: docker/build-push-action@v2
with:
builder: ${{ steps.buildx.outputs.name }}
context: ./dapr-distributed-calendar/${{ matrix.container }}
# file: ./Dockerfile
push: ${{ github.event_name != 'pull_request' && needs.prebuild.outputs.version != '' }}
tags: ${{ steps.prep.outputs.tags }}
platforms: ${{ env.platforms }}