Skip to content

Commit

Permalink
Merge pull request #49 from arturcic/main
Browse files Browse the repository at this point in the history
CI workflows refactoring
  • Loading branch information
arturcic authored Jan 21, 2025
2 parents 02ebe73 + c92f9cc commit e410ef6
Show file tree
Hide file tree
Showing 19 changed files with 562 additions and 347 deletions.
36 changes: 36 additions & 0 deletions .github/actions/build-deps-manifest/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: 'Build Deps Manifest'
description: 'Docker Build Deps Images Manifest'
inputs:
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 Deps manifest] ${{ inputs.docker_registry }}'
shell: pwsh
run: |
dotnet run/build.dll `
--target=DockerBuildDepsManifest `
--docker_distro=${{ inputs.docker_distro }} --docker_registry=${{ inputs.docker_registry_name }} `
--push_images=${{ env.PUSH_IMAGES }} --verbosity=diagnostic
39 changes: 39 additions & 0 deletions .github/actions/build-deps/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: 'Build Deps'
description: 'Docker Build Deps Images'
inputs:
arch:
description: 'OS architecture'
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 Deps] ${{ inputs.docker_registry }}'
shell: pwsh
run: |
dotnet run/build.dll `
--target=DockerBuildDeps --arch=${{ inputs.arch }} `
--docker_distro=${{ inputs.docker_distro }} --docker_registry=${{ inputs.docker_registry_name }} `
--push_images=${{ env.PUSH_IMAGES }} --verbosity=diagnostic
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
16 changes: 16 additions & 0 deletions .github/actions/docker-setup/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: 'Docker Setup'
description: 'Setups the docker engine'

runs:
using: 'composite'
steps:
- 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
50 changes: 25 additions & 25 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
version: 2
updates:
- package-ecosystem: dotnet-sdk
labels:
- "dependencies"
commit-message:
prefix: "(deps)"
directory: "/build"
schedule:
interval: daily
- package-ecosystem: nuget
labels:
- "dependencies"
commit-message:
prefix: "(deps)"
directory: "/build"
schedule:
interval: daily
open-pull-requests-limit: 10
- package-ecosystem: github-actions
labels:
- "dependencies"
commit-message:
prefix: "(build deps)"
directory: "/"
schedule:
interval: daily
- package-ecosystem: dotnet-sdk
labels:
- "dependencies"
commit-message:
prefix: "(deps)"
directory: "/build"
schedule:
interval: daily
- package-ecosystem: nuget
labels:
- "dependencies"
commit-message:
prefix: "(deps)"
directory: "/build"
schedule:
interval: daily
open-pull-requests-limit: 10
- package-ecosystem: github-actions
labels:
- "dependencies"
commit-message:
prefix: "(build deps)"
directory: "/"
schedule:
interval: daily
40 changes: 20 additions & 20 deletions .github/mergify.yml
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
pull_request_rules:
- name: Automatic approve on dependabot PR
conditions:
- author~=^dependabot(|-preview)\[bot\]$
actions:
review:
type: APPROVE
- name: Automatic merge on dependabot PR after success CI
conditions:
- author~=^dependabot(|-preview)\[bot\]$
- '#commits-behind=0' # Only merge up to date pull requests
- repository-full-name=GitTools/build-images # Don't auto-merge PRs in forks
actions:
merge:
- name: Thank contributor
conditions:
- merged
- -author~=^dependabot(|-preview)\[bot\]$
actions:
comment:
message: "Thank you @{{author}} for your contribution!"
- name: Automatic approve on dependabot PR
conditions:
- author~=^dependabot(|-preview)\[bot\]$
actions:
review:
type: APPROVE
- name: Automatic merge on dependabot PR after success CI
conditions:
- author~=^dependabot(|-preview)\[bot\]$
- '#commits-behind=0' # Only merge up to date pull requests
- repository-full-name=GitTools/build-images # Don't auto-merge PRs in forks
actions:
merge:
- name: Thank contributor
conditions:
- merged
- -author~=^dependabot(|-preview)\[bot\]$
actions:
comment:
message: "Thank you @{{author}} for your contribution!"
50 changes: 50 additions & 0 deletions .github/workflows/_build-deps-manifest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
on:
workflow_call:
inputs:
docker_distros:
required: true
type: string
env:
DOTNET_INSTALL_DIR: "./.dotnet"
DOTNET_ROLL_FORWARD: "Major"
PUSH_IMAGES: ${{ github.event_name != 'pull_request' && github.repository_owner == 'GitTools' }}

jobs:
build_deps_manifests:
name: ${{ matrix.docker_distro }}
runs-on: ubuntu-24.04
strategy:
fail-fast: false
matrix:
docker_distro: ${{ fromJson(inputs.docker_distros) }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Use cached cake frosting
id: cache-cake
uses: actions/cache@v4
with:
path: run
key: run-${{ runner.os }}-${{ hashFiles('./build/**') }}
- name: Setup .NET SDK
uses: actions/setup-dotnet@v4
with:
global-json-file: build/global.json
- name: Set up Docker
uses: ./.github/actions/docker-setup
- name: Publish image manifest to DockerHub
uses: ./.github/actions/build-deps-manifest
with:
docker_distro: ${{ matrix.docker_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-deps-manifest
with:
docker_distro: ${{ matrix.docker_distro }}
docker_registry: ghcr.io
docker_registry_name: github
docker_registry_username: ${{ github.repository_owner }}
docker_registry_password: ${{ secrets.DOCKER_GITHUB_TOKEN }}
58 changes: 58 additions & 0 deletions .github/workflows/_build-deps.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
on:
workflow_call:
inputs:
runner:
required: true
type: string
arch:
required: true
type: string
docker_distros:
required: true
type: string
env:
DOTNET_INSTALL_DIR: "./.dotnet"
DOTNET_ROLL_FORWARD: "Major"
PUSH_IMAGES: ${{ github.event_name != 'pull_request' && github.repository_owner == 'GitTools' }}

jobs:
build_deps:
name: ${{ matrix.docker_distro }}
runs-on: ${{ inputs.runner }}
strategy:
fail-fast: false
matrix:
docker_distro: ${{ fromJson(inputs.docker_distros) }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Use cached cake frosting
id: cache-cake
uses: actions/cache@v4
with:
path: run
key: run-${{ runner.os }}-${{ hashFiles('./build/**') }}
- name: Setup .NET SDK
uses: actions/setup-dotnet@v4
with:
global-json-file: build/global.json
- name: Set up Docker
uses: ./.github/actions/docker-setup
- name: Publish image to DockerHub
uses: ./.github/actions/build-deps
with:
arch: ${{ inputs.arch }}
docker_distro: ${{ matrix.docker_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-deps
with:
arch: ${{ inputs.arch }}
docker_distro: ${{ matrix.docker_distro }}
docker_registry: ghcr.io
docker_registry_name: github
docker_registry_username: ${{ github.repository_owner }}
docker_registry_password: ${{ secrets.DOCKER_GITHUB_TOKEN }}
Loading

0 comments on commit e410ef6

Please sign in to comment.