Skip to content

Commit

Permalink
add pre-commit and split ansible
Browse files Browse the repository at this point in the history
  • Loading branch information
APN-Pucky committed Nov 28, 2024
1 parent 616b486 commit 80c40fc
Show file tree
Hide file tree
Showing 5 changed files with 196 additions and 4 deletions.
93 changes: 93 additions & 0 deletions .github/workflows/gentoo-ansible.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
name: gentoo-ansible Docker Image CI

on:
push:
branches: [ "master" ]
paths:
- gentoo/ansibl/Dockerfile
- .github/workflows/gentoo-ansible.yml
schedule:
- cron: 0 6 14 * *

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true


jobs:
docker:
runs-on: ubuntu-latest
#runs-on: self-hosted
timeout-minutes: 4320 # 72h
strategy:
fail-fast: false
max-parallel: 1
matrix:
user: ["apnpucky"]
base: [ "gentoo" ]
image: [
"ansible",
]
platforms: [
"linux/amd64,linux/arm64,linux/riscv64"
#,linux/386, linux/ppc64le,linux/arm/v5,linux/arm/v6,linux/arm/v7, #,linux/s390x,
]
ansible: [ "10.2.0" ]
steps:
-
name: Set up version
id: version
run: |
VERSION=${{ matrix.image }}
VERSION=${VERSION//ansible/${{ matrix.ansible }}}
echo "VERSION=$VERSION" >> "$GITHUB_OUTPUT"
-
name: Checkout
uses: actions/checkout@v3
-
name: Get current time
uses: josStorer/get-current-time@v2.0.2
id: current-time
with:
format: YYYYMMDDHHSS
-
name: Set up QEMU
uses: docker/setup-qemu-action@v2
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
with:
config: .github/buildkitd.toml
-
name: Login to Docker Hub
uses: docker/#-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
-
name: abort on existing tag
id: abort
run: |
if docker manifest inspect ${{ matrix.user }}/${{ matrix.base }}-${{ matrix.image }}:${{ steps.version.outputs.VERSION }}-${{ github.sha }}-latest; then
echo "STOP"
echo "STOP=true" >> "$GITHUB_OUTPUT"
else
echo "DONT STOP"
echo "STOP=false" >> "$GITHUB_OUTPUT"
fi
-
name: ${{ matrix.base }}-${{ matrix.image }}
if: steps.abort.outputs.STOP == 'false'
uses: docker/build-push-action@v3
with:
file: gentoo/ansible/Dockerfile
platforms: ${{ matrix.platforms }}
push: true
target: ${{ matrix.base }}-${{ matrix.image }}
build-args: |
ANSIBLE_VERSION=${{ matrix.ansible }}
tags: |
${{ matrix.user }}/${{ matrix.base }}-${{ matrix.image }}:latest
${{ matrix.user }}/${{ matrix.base }}-${{ matrix.image }}:${{ steps.version.outputs.VERSION }}-latest
${{ matrix.user }}/${{ matrix.base }}-${{ matrix.image }}:${{ steps.version.outputs.VERSION }}-${{ github.sha }}-latest
${{ matrix.user }}/${{ matrix.base }}-${{ matrix.image }}:${{ steps.version.outputs.VERSION }}-${{ steps.current-time.outputs.formattedTime }}-latest
93 changes: 93 additions & 0 deletions .github/workflows/gentoo-pre-commit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
name: gentoo-pre-commit Docker Image CI

on:
push:
branches: [ "master" ]
paths:
- gentoo/pre-commit/Dockerfile
- .github/workflows/gentoo-pre-commit.yml
schedule:
- cron: 0 6 14 * *

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true


jobs:
docker:
runs-on: ubuntu-latest
#runs-on: self-hosted
timeout-minutes: 4320 # 72h
strategy:
fail-fast: false
max-parallel: 1
matrix:
user: ["apnpucky"]
base: [ "gentoo" ]
image: [
"pre-commit",
]
platforms: [
"linux/amd64,linux/arm/v7,linux/arm64,linux/riscv64"
#,linux/386, linux/arm64,linux/ppc64le,linux/riscv64,linux/arm/v5,linux/arm/v6,linux/arm/v7, #,linux/s390x,
]
pre-commit: [ "3.8.0" ]
steps:
-
name: Set up version
id: version
run: |
VERSION=${{ matrix.image }}
VERSION=${VERSION//pre-commit/${{ matrix.pre-commit }}}
echo "VERSION=$VERSION" >> "$GITHUB_OUTPUT"
-
name: Checkout
uses: actions/checkout@v3
-
name: Get current time
uses: josStorer/get-current-time@v2.0.2
id: current-time
with:
format: YYYYMMDDHHSS
-
name: Set up QEMU
uses: docker/setup-qemu-action@v2
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
with:
config: .github/buildkitd.toml
-
name: Login to Docker Hub
uses: docker/#-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
-
name: abort on existing tag
id: abort
run: |
if docker manifest inspect ${{ matrix.user }}/${{ matrix.base }}-${{ matrix.image }}:${{ steps.version.outputs.VERSION }}-${{ github.sha }}-latest; then
echo "STOP"
echo "STOP=true" >> "$GITHUB_OUTPUT"
else
echo "DONT STOP"
echo "STOP=false" >> "$GITHUB_OUTPUT"
fi
-
name: ${{ matrix.base }}-${{ matrix.image }}
if: steps.abort.outputs.STOP == 'false'
uses: docker/build-push-action@v3
with:
file: gentoo/pre-commit/Dockerfile
platforms: ${{ matrix.platforms }}
push: true
target: ${{ matrix.base }}-${{ matrix.image }}
build-args: |
PRE_COMMIT_VERSION=${{ matrix.pre-commit }}
tags: |
${{ matrix.user }}/${{ matrix.base }}-${{ matrix.image }}:latest
${{ matrix.user }}/${{ matrix.base }}-${{ matrix.image }}:${{ steps.version.outputs.VERSION }}-latest
${{ matrix.user }}/${{ matrix.base }}-${{ matrix.image }}:${{ steps.version.outputs.VERSION }}-${{ github.sha }}-latest
${{ matrix.user }}/${{ matrix.base }}-${{ matrix.image }}:${{ steps.version.outputs.VERSION }}-${{ steps.current-time.outputs.formattedTime }}-latest
4 changes: 0 additions & 4 deletions gentoo/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,6 @@ RUN eix-update
FROM apnpucky/gentoo-repo as gentoo-ebuild-ci
RUN emerge -q dev-util/pkgdev && rm -rf /var/cache/distfiles/*

# gentoo-ansible
FROM apnpucky/gentoo-repo as gentoo-ansible
RUN ACCEPT_KEYWORDS="* ~*" emerge -q app-admin/ansible-lint app-admin/ansible && rm -rf /var/cache/distfiles/*

# gentoo-rust
FROM apnpucky/gentoo-ebuild-ci as gentoo-rust
RUN emerge -q rust-bin && rm -rf /var/cache/distfiles/*
Expand Down
5 changes: 5 additions & 0 deletions gentoo/ansible/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
FROM apnpucky/gentoo-repo as gentoo-ansible
LABEL maintainer="APN-Pucky"
ARG ANSIBLE_VERSION=10.2.0
RUN echo 'app-admin/ansible-lint * ~*' > /etc/portage/package.accept_keywords/ansible-lint
RUN emerge -q app-admin/ansible-lint ~app-admin/ansible-${ANSIBLE_VERSION} && rm -rf /var/cache/distfiles/*
5 changes: 5 additions & 0 deletions gentoo/pre-commit/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# gentoo-ansible
FROM apnpucky/gentoo-repo as gentoo-pre-commit
ARG PRE_COMMIT_VERSION=3.8.0
RUN echo 'dev-vcs/pre-commit * ~*' > /etc/portage/package.accept_keywords/pre-commit
RUN emerge -q ~dev-vcs/pre-commit-${PRE_COMMIT_VERSION} && rm -rf /var/cache/distfiles/*

0 comments on commit 80c40fc

Please # to comment.