Draft2 #27
Workflow file for this run
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: builds | |
on: | |
release: | |
types: [ created ] | |
push: | |
branches: | |
- main | |
pull_request: | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.head_ref || github.sha }} | |
cancel-in-progress: true | |
env: | |
arch_amd64: amd64 | |
arch_arm64: arm64 | |
docker_images: | | |
name=rudderstack/rudder-load | |
docker_tags: | | |
type=ref,event=branch | |
type=raw,value=${{ github.head_ref }},enable=${{ github.event_name == 'pull_request' }} | |
type=raw,value=latest,enable=${{ github.event_name == 'release' }} | |
type=semver,pattern={{version}},enable=${{ github.ref == format('refs/heads/{0}', 'main') || github.event_name == 'release' }} | |
type=semver,pattern={{major}},enable=${{ github.ref == format('refs/heads/{0}', 'main') || github.event_name == 'release' }} | |
type=semver,pattern={{major}}.{{minor}},enable=${{ github.ref == format('refs/heads/{0}', 'main') || github.event_name == 'release' }} | |
jobs: | |
docker-meta: | |
runs-on: ubuntu-latest | |
outputs: | |
labels: ${{ steps.meta.outputs.labels }} | |
build-date: ${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.created'] }} | |
version: ${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.version'] }} | |
revision: ${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.revision'] }} | |
tags: ${{ steps.meta.outputs.tags }} | |
arm64_tags: ${{ steps.arm64_meta.outputs.tags }} | |
arm64_labels: ${{ steps.arm64_meta.outputs.labels }} | |
amd64_tags: ${{ steps.amd64_meta.outputs.tags }} | |
amd64_labels: ${{ steps.amd64_meta.outputs.labels }} | |
steps: | |
- name: Docker meta | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: ${{env.docker_images}} | |
tags: ${{env.docker_tags}} | |
- name: Docker arm64 meta | |
id: arm64_meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: ${{env.docker_images}} | |
tags: ${{env.docker_tags}} | |
flavor: | | |
suffix=-${{env.arch_arm64}},onlatest=true | |
- name: Docker amd64 meta | |
id: amd64_meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: ${{env.docker_images}} | |
tags: ${{env.docker_tags}} | |
flavor: | | |
suffix=-${{env.arch_amd64}},onlatest=true | |
docker: | |
needs: | |
- docker-meta | |
strategy: | |
matrix: | |
build-config: | |
- os: [ self-hosted, Linux, ARM64 ] | |
tags: ${{needs.docker-meta.outputs.arm64_tags}} | |
labels: ${{needs.docker-meta.outputs.arm64_labels}} | |
platform: linux/arm64 | |
- os: ubuntu-latest | |
tags: ${{needs.docker-meta.outputs.amd64_tags}} | |
labels: ${{needs.docker-meta.outputs.amd64_labels}} | |
platform: linux/amd64 | |
runs-on: ${{matrix.build-config.os}} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Login to DockerHub | |
uses: docker/login-action@v3 | |
with: | |
username: rudderlabs | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Build and push | |
uses: docker/build-push-action@v6 | |
with: | |
platforms: ${{ matrix.build-config.platform }} | |
push: true | |
tags: ${{ matrix.build-config.tags }} | |
labels: ${{ matrix.build-config.labels }} | |
build-args: | | |
BUILD_DATE=${{ needs.docker-meta.outputs.build-date }} | |
VERSION=${{ needs.docker-meta.outputs.version }} | |
COMMIT_HASH=${{ github.sha }} | |
REVISION=${{ needs.docker-meta.outputs.revision }} | |
create-manifest: | |
runs-on: ubuntu-latest | |
needs: [ docker, docker-meta ] | |
steps: | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to DockerHub | |
uses: docker/login-action@v3.1.0 | |
with: | |
username: rudderlabs | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Create multi-arch manifest for Docker | |
run: | | |
while read -r tag; do | |
echo "$tag" | |
arm_tag=$(echo "${{ needs.docker-meta.outputs.arm64_tags }}" | grep "$tag") | |
echo "$arm_tag" | |
amd_tag=$(echo "${{ needs.docker-meta.outputs.amd64_tags }}" | grep "$tag") | |
echo "$amd_tag" | |
docker buildx imagetools create -t $tag $arm_tag $amd_tag | |
done <<< "${{ needs.docker-meta.outputs.tags }}" |