with service ?
Some checks failed
Build and Push Ansible Container / build-and-push (arm64) (push) Failing after 30s
Build and Push Ansible Container / build-and-push (amd64) (push) Failing after 31s
Build and Push Ansible Container / manifest (push) Has been skipped
Build and Push Docker-in-Docker Container / build-and-push (amd64) (push) Failing after 45s
Build and Push Docker-in-Docker Container / build-and-push (arm64) (push) Failing after 47s
Build and Push Docker-in-Docker Container / create-manifest (push) Has been skipped
Some checks failed
Build and Push Ansible Container / build-and-push (arm64) (push) Failing after 30s
Build and Push Ansible Container / build-and-push (amd64) (push) Failing after 31s
Build and Push Ansible Container / manifest (push) Has been skipped
Build and Push Docker-in-Docker Container / build-and-push (amd64) (push) Failing after 45s
Build and Push Docker-in-Docker Container / build-and-push (arm64) (push) Failing after 47s
Build and Push Docker-in-Docker Container / create-manifest (push) Has been skipped
This commit is contained in:
parent
28e2f61a42
commit
e8920989dd
2 changed files with 104 additions and 34 deletions
|
|
@ -1,10 +1,14 @@
|
|||
# Workflow name
|
||||
name: Build and Push Ansible Container
|
||||
|
||||
# Run-name for each workflow run
|
||||
run-name: Build and Push Ansible Container
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
paths:
|
||||
- 'containers/${{ github.workflow }}/**' # This path will look for 'containers/Build and Push Ansible Container/**'
|
||||
- 'containers/ansible/**'
|
||||
- '.forgejo/workflows/ansible.yml'
|
||||
workflow_dispatch: {}
|
||||
schedule:
|
||||
|
|
@ -16,20 +20,29 @@ jobs:
|
|||
matrix:
|
||||
arch: [ amd64, arm64 ]
|
||||
runs-on: ${{ matrix.arch }}
|
||||
container:
|
||||
image: node:latest
|
||||
volumes:
|
||||
- /var/run/docker.sock:/var/run/docker.sock
|
||||
services:
|
||||
dind:
|
||||
image: docker:dind
|
||||
privileged: true
|
||||
env:
|
||||
DOCKER_HOST: tcp://dind:2375
|
||||
steps:
|
||||
|
||||
- name: Install Docker CLI
|
||||
run: |
|
||||
apt-get update
|
||||
apt-get install -y docker.io
|
||||
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Wait for Docker to start
|
||||
run: |
|
||||
i=0
|
||||
while ! docker info >/dev/null 2>&1;
|
||||
i=$((i+1))
|
||||
if [ $i -ge 15 ]; then
|
||||
echo "Docker did not start within 15 seconds"
|
||||
exit 1
|
||||
fi
|
||||
echo "Waiting for Docker to start..."
|
||||
sleep 1
|
||||
done
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
|
|
@ -40,30 +53,40 @@ jobs:
|
|||
username: ${{ secrets.CI_REGISTRY_USER }}
|
||||
password: ${{ secrets.CI_TOKEN }}
|
||||
|
||||
# Removed the `cd` step as `context` and `file` can handle the path directly.
|
||||
|
||||
- name: Build and push (${{ matrix.arch }})
|
||||
uses: docker/build-push-action@v5
|
||||
with:
|
||||
context: ./containers/${{ github.workflow }}/ # Relative to the checkout root
|
||||
file: ./containers/${{ github.workflow }}/Dockerfile # Relative to the checkout root
|
||||
context: ./containers/ansible/
|
||||
file: ./containers/ansible/Dockerfile
|
||||
platforms: linux/${{ matrix.arch }}
|
||||
push: true
|
||||
tags: |
|
||||
${{ secrets.CI_REGISTRY }}/${{ secrets.CI_REPOSITORY }}:${{ matrix.arch }}-latest
|
||||
cache-from: type=registry,ref=${{ secrets.CI_REGISTRY }}/${{ secrets.CI_REPOSITORY }}:buildcache-${{ matrix.arch }} # Add caching
|
||||
cache-to: type=registry,ref=${{ secrets.CI_REGISTRY }}/${{ secrets.CI_REPOSITORY }}:buildcache-${{ matrix.arch }},mode=max # Add caching
|
||||
${{ secrets.CI_REGISTRY }}/${{ secrets.CI_REPOSITORY }}/ansible:${{ matrix.arch }}-latest
|
||||
cache-from: type=registry,ref=${{ secrets.CI_REGISTRY }}/${{ secrets.CI_REPOSITORY }}/ansible:buildcache-${{ matrix.arch }}
|
||||
cache-to: type=registry,ref=${{ secrets.CI_REGISTRY }}/${{ secrets.CI_REPOSITORY }}/ansible:buildcache-${{ matrix.arch }},mode=max
|
||||
|
||||
manifest:
|
||||
needs: build-and-push
|
||||
runs-on: ubuntu-latest # or amd64 if you have a specific AMD64 runner for manifest creation
|
||||
runs-on: amd64
|
||||
services:
|
||||
dind:
|
||||
image: docker:dind
|
||||
privileged: true
|
||||
env:
|
||||
DOCKER_HOST: tcp://dind:2375
|
||||
steps:
|
||||
- name: Install Docker CLI
|
||||
- name: Wait for Docker to start
|
||||
run: |
|
||||
# Ensure docker CLI is available in the runner environment for `docker manifest`
|
||||
# Most `ubuntu-latest` runners already have it, but explicit is better.
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y docker-ce-cli # Install only the client if the runner is not dind
|
||||
i=0
|
||||
while ! docker info >/dev/null 2>&1;
|
||||
i=$((i+1))
|
||||
if [ $i -ge 15 ]; then
|
||||
echo "Docker did not start within 15 seconds"
|
||||
exit 1
|
||||
fi
|
||||
echo "Waiting for Docker to start..."
|
||||
sleep 1
|
||||
done
|
||||
|
||||
- name: Login to Forgejo Registry
|
||||
uses: docker/login-action@v3
|
||||
|
|
@ -74,8 +97,7 @@ jobs:
|
|||
|
||||
- name: Create and push multi-arch manifest
|
||||
run: |
|
||||
# Use the explicit "docker" command which should be available
|
||||
docker manifest create ${{ secrets.CI_REGISTRY }}/${{ secrets.CI_REPOSITORY }}:latest \
|
||||
${{ secrets.CI_REGISTRY }}/${{ secrets.CI_REPOSITORY }}:amd64-latest \
|
||||
${{ secrets.CI_REGISTRY }}/${{ secrets.CI_REPOSITORY }}:arm64-latest
|
||||
docker manifest push ${{ secrets.CI_REGISTRY }}/${{ secrets.CI_REPOSITORY }}:latest
|
||||
docker manifest create ${{ secrets.CI_REGISTRY }}/${{ secrets.CI_REPOSITORY }}/ansible:latest \
|
||||
--amend ${{ secrets.CI_REGISTRY }}/${{ secrets.CI_REPOSITORY }}/ansible:amd64-latest \
|
||||
--amend ${{ secrets.CI_REGISTRY }}/${{ secrets.CI_REPOSITORY }}/ansible:arm64-latest
|
||||
docker manifest push ${{ secrets.CI_REGISTRY }}/${{ secrets.CI_REPOSITORY }}/ansible:latest
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue