diff --git a/.gitea/workflows/test_build_and_push.yaml b/.gitea/workflows/test_build_and_push.yaml index 69a55e9..cfe575a 100644 --- a/.gitea/workflows/test_build_and_push.yaml +++ b/.gitea/workflows/test_build_and_push.yaml @@ -6,29 +6,21 @@ on: - main jobs: - # test_shellcheck: - # name: check and test - # runs-on: ubuntu-latest - # steps: - # - uses: actions/checkout@v4 - # - name: Install shellcheck - # run: apt update && apt install -y shellcheck - # - name: test - # run: ./shellcheck.sh - buildpush: - name: build_and_push - # needs: [tests_shellcheck] + test_shellcheck: + name: check and test + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Install shellcheck + run: apt update && apt install -y shellcheck + - name: test + run: ./shellcheck.sh + buildpush: + name: build_and_push + needs: [tests_shellcheck] runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - # - name: Login to docker - # run: mkdir -p $HOME/.docker && cp config.json $HOME/.docker/config.json - # - name: Install docker - # run: curl -fsSL https://get.docker.com | sh - # - name: Install parallel - # run: apt install parallel -y - # - name: Build docker container - # run: ./build-all.sh && exit 0 - name: Kaniko build htop uses: aevea/action-kaniko@master with: @@ -48,3 +40,73 @@ jobs: password: ${{ secrets.DOCKERHUB_PASSWORD }} cache: false exra_args: --cleanup + + - name: Kaniko build mtr + uses: aevea/action-kaniko@master + with: + image: uleenucks/mtr + path: mtr + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_PASSWORD }} + cache: false + exra_args: --cleanup + + - name: Kaniko build nmap + uses: aevea/action-kaniko@master + with: + image: uleenucks/nmap + path: nmap + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_PASSWORD }} + cache: false + exra_args: --cleanup + + - name: Kaniko build postgres-backup + uses: aevea/action-kaniko@master + with: + image: uleenucks/postgres-backup + path: postgres-backup + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_PASSWORD }} + cache: false + exra_args: --cleanup + + - name: Kaniko build pyweb + uses: aevea/action-kaniko@master + with: + image: uleenucks/pyweb + path: pyweb + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_PASSWORD }} + cache: false + exra_args: --cleanup + + - name: Kaniko build shellcheck + uses: aevea/action-kaniko@master + with: + image: uleenucks/shellcheck + path: shellcheck + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_PASSWORD }} + cache: false + exra_args: --cleanup + + - name: Kaniko build traceroute + uses: aevea/action-kaniko@master + with: + image: uleenucks/traceroute + path: traceroute + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_PASSWORD }} + cache: false + exra_args: --cleanup + + - name: Kaniko build vaultwarden-backup + uses: aevea/action-kaniko@master + with: + image: uleenucks/vaultwarden-backup + path: vaultwarden-backup + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_PASSWORD }} + cache: false + exra_args: --cleanup diff --git a/build-all.sh b/build-all.sh deleted file mode 100755 index 8e4134a..0000000 --- a/build-all.sh +++ /dev/null @@ -1,94 +0,0 @@ -#!/bin/bash -set -e -set -o pipefail - -SCRIPT="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/$(basename "${BASH_SOURCE[0]}")" -REPO_URL="${REPO_URL:-uleenucks}" -JOBS=${JOBS:-2} -DOCKER="$(which docker)" - -ERRORS="$(pwd)/errors" - -dcleanup(){ - "${DOCKER}" rm "$(${DOCKER} ps -aq 2>/dev/null)" 2>/dev/null - "${DOCKER}" rm -v "$(${DOCKER} ps --filter status=exited -q 2>/dev/null)" 2>/dev/null - "${DOCKER}" rmi "$(${DOCKER} images --filter dangling=true -q 2>/dev/null)" 2>/dev/null -} - -build_and_push(){ - base=$1 - suite=$2 - build_dir=$3 - - echo "Building ${REPO_URL}/${base}:${suite} for context ${build_dir}" - docker build --rm --force-rm -t "${REPO_URL}/${base}:${suite}" "${build_dir}" || return 1 - - # on successful build, push the image - echo " --- " - echo "Successfully built ${base}:${suite} with context ${build_dir}" - echo " --- " - - # try push a few times because notary server sometimes returns 401 for - # absolutely no reason - n=0 - until [ $n -ge 5 ]; do - docker push --disable-content-trust=false "${REPO_URL}/${base}:${suite}" && break - echo "Try #$n failed... sleeping for 5 seconds" - n=$((n+1)) - sleep 5 - done -} - -dofile() { - f=$1 - image=${f%Dockerfile} - base=${image%%\/*} - build_dir=$(dirname "$f") - suite=${build_dir##*\/} - - if [[ -z "$suite" ]] || [[ "$suite" == "$base" ]]; then - suite=latest - fi - - { - $SCRIPT build_and_push "${base}" "${suite}" "${build_dir}" - } || { - # add to errors - echo "${base}:${suite}" >> "$ERRORS" -} -echo -echo -} - -main(){ - # get the dockerfiles - IFS=$'\n' - mapfile -t files < <(find -L . -iname '*Dockerfile' | sed 's|./||' | sort) - unset IFS - - # build all dockerfiles - echo "Running in parallel with ${JOBS} jobs." - parallel --tag --verbose --ungroup -j"${JOBS}" "$SCRIPT" dofile "{1}" ::: "${files[@]}" - - if [[ ! -f "$ERRORS" ]]; then - echo "No errors, hooray!" - else - echo "[ERROR] Some images did not build correctly, see below." >&2 - echo "These images failed: $(cat "$ERRORS")" >&2 - exit 1 - fi -} - -run(){ - args=$* - f=$1 - - if [[ "$f" == "" ]]; then - main "$args" - else - $args - fi -} - -run "$@" -dcleanup diff --git a/plugin.sh b/plugin.sh deleted file mode 100755 index 0dbcf5b..0000000 --- a/plugin.sh +++ /dev/null @@ -1,81 +0,0 @@ -#!/bin/bash -set -e -set -o pipefail - -SCRIPT="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/$(basename "${BASH_SOURCE[0]}")" -REPO_URL="${REPO_URL:-uleenucks}" -DOCKERFILESPATH="${HOME}/closed/dockerfiles" - -ERRORS="$(pwd)/errors" - -build_and_push_kaniko(){ - base=$1 - suite=$2 - build_dir=$3 - - echo "Building ${REPO_URL}/${base}:${suite} for context ${build_dir}" - - /kaniko/executor \ - --dockerfile="${build_dir}" \ - --destination="${REPO_URL}/${base}:${suite}" \ - --force \ - --cleanup \ - || return 1 - - # on successful build, push the image - echo " --- " - echo "Successfully built and pushed ${base}:${suite} with context ${build_dir}" - echo " --- " -} - -dofile() { - f=$1 - image=${f%Dockerfile} - base=${image%%\/*} - build_dir=$(dirname "$f") - suite=${build_dir##*\/} - - if [[ -z "$suite" ]] || [[ "$suite" == "$base" ]]; then - suite=latest - fi - - { - $SCRIPT build_and_push_kaniko "${base}" "${suite}" "${build_dir}" - } || { - # add to errors - echo "${base}:${suite}" >> "$ERRORS" - } - echo - echo -} - -main(){ - # get the dockerfiles - IFS=$'\n' - files=( $(find . -iname '*Dockerfile' | sed 's|./||' | sort) ) - unset IFS - - # build all dockerfiles - "$SCRIPT" dofile "{1}" ::: "${files[@]}" - - if [[ ! -f $ERRORS ]]; then - echo "No errors, hooray!" - else - echo "[ERROR] Some images did not build correctly, see below." >&2 - echo "These images failed: $(cat "$ERRORS")" >&2 - exit 1 - fi -} - -run(){ - args=$@ - f=$1 - - if [[ "$f" == "" ]]; then - main "$args" - else - $args - fi -} - -run $@ \ No newline at end of file diff --git a/shellcheck.sh b/shellcheck.sh index 4edd81a..45ea112 100755 --- a/shellcheck.sh +++ b/shellcheck.sh @@ -5,7 +5,7 @@ set -o pipefail ERRORS=() # find all executables and run `shellcheck` -for f in $(find . -type f -not -iwholename '*.git*' -not -name "Dockerfile" -not -name "plugin.sh" | sort -u); do +for f in $(find . -type f -not -iwholename '*.git*' -not -name "Dockerfile" | sort -u); do if file "$f" | grep --quiet shell; then { shellcheck "$f" && echo "[OK]: sucessfully linted $f"