From a348071b01af93312621bb5f7917ee3df9984031 Mon Sep 17 00:00:00 2001 From: Artur Stolear Date: Mon, 20 Jan 2025 23:38:50 +0100 Subject: [PATCH] use shared local action for deps --- .../actions/build-deps-manifest/action.yml | 36 +++++++ .github/actions/build-deps/action.yml | 39 +++++++ .github/actions/docker-setup/action.yml | 16 +++ .github/workflows/build-deps.yml | 102 ++++++------------ 4 files changed, 123 insertions(+), 70 deletions(-) create mode 100644 .github/actions/build-deps-manifest/action.yml create mode 100644 .github/actions/build-deps/action.yml create mode 100644 .github/actions/docker-setup/action.yml diff --git a/.github/actions/build-deps-manifest/action.yml b/.github/actions/build-deps-manifest/action.yml new file mode 100644 index 0000000..7a0cd85 --- /dev/null +++ b/.github/actions/build-deps-manifest/action.yml @@ -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=DockerBuildDeps --arch=${{ inputs.arch }} ` + --dotnet_distro=${{ inputs.docker_distro }} --docker_registry=${{ inputs.docker_registry_name }} ` + --push_images=${{ env.PUSH_IMAGES }} --verbosity=diagnostic diff --git a/.github/actions/build-deps/action.yml b/.github/actions/build-deps/action.yml new file mode 100644 index 0000000..da4d612 --- /dev/null +++ b/.github/actions/build-deps/action.yml @@ -0,0 +1,39 @@ +name: 'Build Deps' +description: 'Docker Build Deps Images' +inputs: + arch: + description: 'Docker 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 images] ${{ inputs.docker_registry }}' + shell: pwsh + run: | + dotnet run/build.dll ` + --target=DockerBuildDeps --arch=${{ inputs.arch }} ` + --dotnet_distro=${{ inputs.docker_distro }} --docker_registry=${{ inputs.docker_registry_name }} ` + --push_images=${{ env.PUSH_IMAGES }} --verbosity=diagnostic diff --git a/.github/actions/docker-setup/action.yml b/.github/actions/docker-setup/action.yml new file mode 100644 index 0000000..7b75ceb --- /dev/null +++ b/.github/actions/docker-setup/action.yml @@ -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 diff --git a/.github/workflows/build-deps.yml b/.github/workflows/build-deps.yml index 12fe6ca..be570d3 100644 --- a/.github/workflows/build-deps.yml +++ b/.github/workflows/build-deps.yml @@ -70,43 +70,25 @@ jobs: with: global-json-file: build/global.json - name: Set up Docker - uses: docker/setup-docker-action@v4 + uses: ./.github/actions/docker-setup + - name: Publish image to DockerHub + uses: ./.github/actions/build-deps with: - daemon-config: '{ "features": { "containerd-snapshotter": true } }' - - name: Setup Docker Buildx - uses: docker/setup-buildx-action@v3 + arch: ${{ matrix.arch }} + 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-deps 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] DockerHub' - shell: pwsh - run: | - dotnet run/build.dll ` - --target=DockerBuildDeps --arch=${{ matrix.arch }} ` - --dotnet_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] GitHub' - shell: pwsh - run: | - dotnet run/build.dll ` - --target=DockerBuildDeps --arch=${{ matrix.arch }} ` - --dotnet_distro=${{ matrix.distro }} --docker_registry=github ` - --push_images=${{env.PUSH_IMAGES}} --verbosity=diagnostic + arch: ${{ matrix.arch }} + 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_deps_manifests: name: Build Deps Manifests (${{ matrix.distro }}) @@ -132,40 +114,20 @@ 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 + uses: ./.github/actions/docker-setup + - name: Publish image manifest to DockerHub + uses: ./.github/actions/build-deps-manifest with: - registry: docker.io - username: ${{ secrets.DOCKER_USERNAME }} - password: ${{ secrets.DOCKER_PASSWORD }} - - name: '[Build Docker manifests] DockerHub' - shell: pwsh - run: | - dotnet run/build.dll ` - --target=DockerBuildDepsManifest ` - --dotnet_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 + 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-deps-manifest with: - registry: ghcr.io - username: ${{ github.repository_owner }} - password: ${{ secrets.DOCKER_GITHUB_TOKEN }} - - name: '[Build Docker manifests] GitHub' - shell: pwsh - run: | - dotnet run/build.dll ` - --target=DockerBuildDepsManifest ` - --dotnet_distro=${{ matrix.distro }} --docker_registry=github ` - --push_images=${{env.PUSH_IMAGES}} --verbosity=diagnostic + 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 }}