Skip to content

Commit

Permalink
use shared local action for images
Browse files Browse the repository at this point in the history
  • Loading branch information
arturcic committed Jan 20, 2025
1 parent ef8639e commit 937b751
Show file tree
Hide file tree
Showing 3 changed files with 133 additions and 78 deletions.
43 changes: 43 additions & 0 deletions .github/actions/build-images-manifest/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: 'Build Images Manifest'
description: 'Docker Build Images Manifest'
inputs:
dotnet_version:
description: '.net version'
required: true
dotnet_variant:
description: '.net variant'
required: true
docker_distro:
description: 'Linux Distro'
required: true
docker_registry:
description: 'Docker Registry'
required: true
docker_registry_name:
description: 'Docker Registry Name'
required: true
docker_registry_username:
description: 'Docker Registry Username'
required: true
docker_registry_password:
description: 'Docker Registry Password'
required: true

runs:
using: 'composite'
steps:
- name: Login to ${{ inputs.docker_registry }}
if: ${{ env.PUSH_IMAGES == 'true' }}
uses: docker/login-action@v3
with:
registry: ${{ inputs.docker_registry }}
username: ${{ inputs.docker_registry_username }}
password: ${{ inputs.docker_registry_password }}
- name: '[Build Docker images manifest] ${{ inputs.docker_registry }}'
shell: pwsh
run: |
dotnet run/build.dll `
--target=DockerBuildImagesManifest `
--dotnet_version=${{ inputs.dotnet_version }} --dotnet_variant=${{ inputs.dotnet_variant }} `
--docker_distro=${{ inputs.docker_distro }} --docker_registry=${{ inputs.docker_registry_name }} `
--push_images=${{ env.PUSH_IMAGES }} --verbosity=diagnostic
46 changes: 46 additions & 0 deletions .github/actions/build-images/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: 'Build Images'
description: 'Docker Build Images'
inputs:
arch:
description: 'OS architecture'
required: true
dotnet_version:
description: '.net version'
required: true
dotnet_variant:
description: '.net variant'
required: true
docker_distro:
description: 'Linux Distro'
required: true
docker_registry:
description: 'Docker Registry'
required: true
docker_registry_name:
description: 'Docker Registry Name'
required: true
docker_registry_username:
description: 'Docker Registry Username'
required: true
docker_registry_password:
description: 'Docker Registry Password'
required: true

runs:
using: 'composite'
steps:
- name: Login to ${{ inputs.docker_registry }}
if: ${{ env.PUSH_IMAGES == 'true' }}
uses: docker/login-action@v3
with:
registry: ${{ inputs.docker_registry }}
username: ${{ inputs.docker_registry_username }}
password: ${{ inputs.docker_registry_password }}
- name: '[Build Docker images] ${{ inputs.docker_registry }}'
shell: pwsh
run: |
dotnet run/build.dll `
--target=DockerBuildImages --arch=${{ inputs.arch }} `
--dotnet_version=${{ inputs.dotnet_version }} --dotnet_variant=${{ inputs.dotnet_variant }} `
--docker_distro=${{ inputs.docker_distro }} --docker_registry=${{ inputs.docker_registry_name }} `
--push_images=${{ env.PUSH_IMAGES }} --verbosity=diagnostic
122 changes: 44 additions & 78 deletions .github/workflows/build-images.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,45 +73,29 @@ jobs:
with:
global-json-file: build/global.json
- name: Set up Docker
uses: docker/setup-docker-action@v4
with:
daemon-config: '{ "features": { "containerd-snapshotter": true } }'
- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v3
with:
version: 'latest'
driver-opts: 'image=moby/buildkit:buildx-stable-1'
install: true
- name: Login to DockerHub
if: success() && env.PUSH_IMAGES == 'true'
uses: docker/login-action@v3
with:
registry: docker.io
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: '[Build Docker images]'
shell: pwsh
run: |
dotnet run/build.dll `
--target=DockerBuildImages --arch=${{ matrix.arch }} `
--dotnet_version=${{ matrix.version }} --dotnet_variant=${{ matrix.variant }} `
--docker_distro=${{ matrix.distro }} --docker_registry=dockerhub `
--push_images=${{env.PUSH_IMAGES}} --verbosity=diagnostic
- name: Login to GitHub Container Registry
if: success() && env.PUSH_IMAGES == 'true'
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.DOCKER_GITHUB_TOKEN }}
- name: '[Build Docker images]'
shell: pwsh
run: |
dotnet run/build.dll `
--target=DockerBuildImages --arch=${{ matrix.arch }} `
--dotnet_version=${{ matrix.version }} --dotnet_variant=${{ matrix.variant }} `
--docker_distro=${{ matrix.distro }} --docker_registry=github `
--push_images=${{env.PUSH_IMAGES}} --verbosity=diagnostic
uses: ./.github/actions/docker-setup
- name: Publish image to DockerHub
uses: ./.github/actions/build-images
with:
arch: ${{ matrix.arch }}
dotnet_version: ${{ matrix.version }}
dotnet_variant: ${{ matrix.variant }}
docker_distro: ${{ matrix.distro }}
docker_registry: docker.io
docker_registry_name: dockerhub
docker_registry_username: ${{ secrets.DOCKER_USERNAME }}
docker_registry_password: ${{ secrets.DOCKER_PASSWORD }}
- name: Publish image to GitHub
uses: ./.github/actions/build-images
with:
arch: ${{ matrix.arch }}
dotnet_version: ${{ matrix.version }}
dotnet_variant: ${{ matrix.variant }}
docker_distro: ${{ matrix.distro }}
docker_registry: ghcr.io
docker_registry_name: github
docker_registry_username: ${{ github.repository_owner }}
docker_registry_password: ${{ secrets.DOCKER_GITHUB_TOKEN }}

build_images_manifest:
name: Build Images (${{ matrix.distro }}) (${{ matrix.version }} - ${{ matrix.variant }})
Expand Down Expand Up @@ -142,42 +126,24 @@ jobs:
with:
global-json-file: build/global.json
- name: Set up Docker
uses: docker/setup-docker-action@v4
with:
daemon-config: '{ "features": { "containerd-snapshotter": true } }'
- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v3
with:
version: 'latest'
driver-opts: 'image=moby/buildkit:buildx-stable-1'
install: true
- name: Login to DockerHub
if: success() && env.PUSH_IMAGES == 'true'
uses: docker/login-action@v3
with:
registry: docker.io
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: '[Build Docker images]'
shell: pwsh
run: |
dotnet run/build.dll `
--target=DockerBuildImagesManifest `
--dotnet_version=${{ matrix.version }} --dotnet_variant=${{ matrix.variant }} `
--docker_distro=${{ matrix.distro }} --docker_registry=dockerhub `
--push_images=${{env.PUSH_IMAGES}} --verbosity=diagnostic
- name: Login to GitHub Container Registry
if: success() && env.PUSH_IMAGES == 'true'
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.DOCKER_GITHUB_TOKEN }}
- name: '[Build Docker images]'
shell: pwsh
run: |
dotnet run/build.dll `
--target=DockerBuildImagesManifest `
--dotnet_version=${{ matrix.version }} --dotnet_variant=${{ matrix.variant }} `
--docker_distro=${{ matrix.distro }} --docker_registry=github `
--push_images=${{env.PUSH_IMAGES}} --verbosity=diagnostic
uses: ./.github/actions/docker-setup
- name: Publish image manifest to DockerHub
uses: ./.github/actions/build-images-manifest
with:
dotnet_version: ${{ matrix.version }}
dotnet_variant: ${{ matrix.variant }}
docker_distro: ${{ matrix.distro }}
docker_registry: docker.io
docker_registry_name: dockerhub
docker_registry_username: ${{ secrets.DOCKER_USERNAME }}
docker_registry_password: ${{ secrets.DOCKER_PASSWORD }}
- name: Publish image manifest to GitHub
uses: ./.github/actions/build-images-manifest
with:
dotnet_version: ${{ matrix.version }}
dotnet_variant: ${{ matrix.variant }}
docker_distro: ${{ matrix.distro }}
docker_registry: ghcr.io
docker_registry_name: github
docker_registry_username: ${{ github.repository_owner }}
docker_registry_password: ${{ secrets.DOCKER_GITHUB_TOKEN }}

0 comments on commit 937b751

Please sign in to comment.