Compare commits
23 Commits
Author | SHA1 | Date | |
---|---|---|---|
70ab7aa80d | |||
53148b13e9 | |||
17619fe844 | |||
1b60aaab69 | |||
24c0f309a8 | |||
00e92ce73c | |||
92afc86488 | |||
425544a9e2 | |||
b7b8c1cc43 | |||
fe5505f5bb | |||
c09ac19197 | |||
3fd7e42cf1 | |||
03978ae7ca | |||
05bda1c7a6 | |||
aac8445456 | |||
556ee2952c | |||
795c9cdd5f | |||
c6819fad58 | |||
b7aeed6996 | |||
775f388990 | |||
ebc3a8886b | |||
42cd5492ad | |||
8c4c43e20c |
15
.gitea/workflows/test.yaml
Normal file
15
.gitea/workflows/test.yaml
Normal file
@ -0,0 +1,15 @@
|
||||
name: Run tests wf
|
||||
on:
|
||||
registry_package:
|
||||
types: [published, updated]
|
||||
|
||||
jobs:
|
||||
build-process:
|
||||
runs-on: alt-sisyphus
|
||||
steps:
|
||||
- name: Check event
|
||||
run: |
|
||||
echo "name package = ${{ github.event.registry_package.name }}"
|
||||
echo "path package = ${{ github.event.registry_package.html_url }}"
|
||||
echo "version package = ${{ github.event.registry_package.package_version.version }}"
|
||||
echo "version package = ${{ github.event.registry_package.package_version.container_metadata.tag.name }}"
|
@ -11,15 +11,16 @@ ORG=${2:-"base"}
|
||||
URL=${3:-"gitea.basealt.ru"}
|
||||
REPO=${4:-"alt"}
|
||||
WS=${5:-"image-forge"}
|
||||
wspath="/workspace/$REPO/$WS"
|
||||
|
||||
errors=''
|
||||
haserr=false
|
||||
for IM in $(ls $WS/org/$ORG/ | xargs)
|
||||
for IM in $(ls $wspath/org/$ORG/ | xargs)
|
||||
do
|
||||
echo "image=$IM"
|
||||
imgpath="$REPO/$WS/$BR/$IM:$BR"
|
||||
imgpath="$REPO/$BR/$ORG/$IM:$BR"
|
||||
command=''
|
||||
testpath="$WS/org/$ORG/$IM/test.yaml"
|
||||
testpath="$wspath/org/$ORG/$IM/test.yaml"
|
||||
if test -f $testpath
|
||||
then
|
||||
entrypoint=''
|
||||
@ -48,14 +49,15 @@ do
|
||||
else
|
||||
echo "not found package name in images labels"
|
||||
fi
|
||||
else
|
||||
then tag=$(date +"%Y%m%d")
|
||||
else tag=$(date +"%Y%m%d")
|
||||
fi
|
||||
|
||||
if [[ $tag != '' ]]
|
||||
then
|
||||
skopeo copy -a docker://$URL/$imgpath:$BR docker://$URL/$imgpath:$tag
|
||||
scopeo delete docker://$URL/$imgpath:$BR
|
||||
echo "newtag=$tag"
|
||||
newimgpath="$REPO/$BR/$ORG/$IM:$tag"
|
||||
skopeo copy -a docker://$URL/$imgpath docker://$URL/$newimgpath
|
||||
#skopeo delete docker://$URL/$imgpath
|
||||
echo "tag is updated"
|
||||
else echo "new tag is empty and is not sent to repository"
|
||||
fi
|
||||
@ -70,7 +72,6 @@ do
|
||||
echo "podman rmi --all"
|
||||
podman rmi --all
|
||||
|
||||
fi
|
||||
haserr=false
|
||||
done
|
||||
|
||||
|
@ -15,6 +15,7 @@ jobs:
|
||||
org: ${{ env.ORG }}
|
||||
url: ${{ env.URL }}
|
||||
repo: ${{ env.REPO }}
|
||||
ws: ${{ env.WS }}
|
||||
buildres: ${{ steps.build-script.outcome }}
|
||||
steps:
|
||||
- name: Check workspace
|
||||
@ -25,6 +26,9 @@ jobs:
|
||||
reponame=$(echo $GR | cut -d '/' -f 1)
|
||||
echo "REPO=$reponame" >> ${GITHUB_ENV}
|
||||
echo $reponame
|
||||
repows=$(echo $GR | cut -d '/' -f 2)
|
||||
echo "WS=$repows" >> ${GITHUB_ENV}
|
||||
echo $repows
|
||||
env:
|
||||
GU: ${{ gitea.server_url }}
|
||||
GR: ${{ gitea.repository }}
|
||||
@ -64,52 +68,57 @@ jobs:
|
||||
- name: Run standart building script
|
||||
id: build-script
|
||||
run: |
|
||||
build_args="-b $BR -o $ORG --skip-images base/distroless-devel --overwrite-organization $BR --registry $URL/${{ gitea.workspace }}/$BR"
|
||||
build_args="-b $BR -o $ORG --skip-images base/distroless-devel --registry $URL/$REPO/$BR -a amd64"
|
||||
echo "build.py $build_args"
|
||||
${{ gitea.workspace }}/build.py $build_args
|
||||
env:
|
||||
ORG: ${{ env.ORG }}
|
||||
BR: ${{ env.BRANCH }}
|
||||
REPO: ${{ env.REPO }}
|
||||
continue-on-error: true
|
||||
- name: Send notification if build crashed
|
||||
if: ${{ steps.build-script.outcome != 'success' }}
|
||||
run: |
|
||||
issueid=1
|
||||
body="Building images finish with some errors."
|
||||
curl -X 'POST' "$URL/api/v1/repos/$REPO/image-forge/issues/$issueid/comments?token=$T" -H 'accept: application/json' -H 'Content-Type: application/json' -d "{ \"body\": \"$body\" }" -s
|
||||
curl -X 'POST' "$URL/api/v1/repos/$REPO/$GWS/issues/$issueid/comments?token=$T" -H 'accept: application/json' -H 'Content-Type: application/json' -d "{ \"body\": \"$body\" }" -s
|
||||
echo "notification about test error is sent to issue $issueid"
|
||||
env:
|
||||
T: ${{ secrets.TOKEN }}
|
||||
BR: ${{ env.BRANCH }}
|
||||
URL: ${{ gitea.server_url }}
|
||||
REPO: ${{ env.REPO }}
|
||||
GWS: ${{ env.WS }}
|
||||
- name: Delete event tag
|
||||
run: |
|
||||
tagname=$(echo $EV | jq '.ref' -r | sed "s/refs\/tags\///g")
|
||||
curl -X 'DELETE' "$URL/api/v1/repos/$REPO/image-forge/tags/$tagname?token=$T" -H 'accept: application/json' -s
|
||||
curl -X 'DELETE' "$URL/api/v1/repos/$REPO/$GWS/tags/$tagname?token=$T" -H 'accept: application/json' -s
|
||||
echo "tag $tagname is deleted"
|
||||
env:
|
||||
T: ${{ secrets.TOKEN }}
|
||||
BR: ${{ env.BRANCH }}
|
||||
URL: ${{ gitea.server_url }}
|
||||
REPO: ${{ env.REPO }}
|
||||
GWS: ${{ env.WS }}
|
||||
EV: ${{ toJson(gitea.event) }}
|
||||
test-process:
|
||||
needs: build-process
|
||||
if: ${{ needs.build-process.outputs.buildres == 'success' }}
|
||||
runs-on: alt-p10
|
||||
outputs:
|
||||
testres: ${{ steps.test-script.outcome }}
|
||||
steps:
|
||||
- name: Update apt
|
||||
uses: actions/init-alt-env@v1
|
||||
- name: Install requires
|
||||
run: |
|
||||
echo "apt-get install -y python3-module-tomli python3-module-jinja2 podman buildah skopeo jq yq curl"
|
||||
apt-get install -y python3-module-tomli python3-module-jinja2 podman buildah jq curl
|
||||
apt-get install -y python3-module-tomli python3-module-jinja2 podman buildah skopeo jq yq curl
|
||||
- name: Check out current repo
|
||||
uses: https://gitea.com/actions/checkout@v4
|
||||
- name: Login podman gitea
|
||||
run: |
|
||||
echo "podman login ${{ env.URL }}"
|
||||
echo "podman login ${{ needs.build-process.outputs.url }}"
|
||||
podman login --username $P_USER --password $P_PASS ${{ needs.build-process.outputs.url }}
|
||||
env:
|
||||
P_USER: ${{ secrets.PODMAN_USER }}
|
||||
@ -118,7 +127,7 @@ jobs:
|
||||
id: test-script
|
||||
continue-on-error: true
|
||||
run: |
|
||||
$WS/.gitea/workflows/testscript $BR $ORG $URL $REPO $WS
|
||||
$WS/.gitea/workflows/testscript $BR $ORG $URL $REPO $GWS
|
||||
cat haserr.log >> ${GITHUB_ENV}
|
||||
echo "test process finished"
|
||||
env:
|
||||
@ -127,16 +136,60 @@ jobs:
|
||||
URL: ${{ needs.build-process.outputs.url }}
|
||||
REPO: ${{ needs.build-process.outputs.repo }}
|
||||
WS: ${{ gitea.workspace }}
|
||||
GWS: ${{ needs.build-process.outputs.ws }}
|
||||
- name: Send notification if test crashed
|
||||
if: ${{ env.ERR == 'true' || steps.test-script.outcome == 'failure' }}
|
||||
run: |
|
||||
issueid=1
|
||||
errors=$(cat errors.log)
|
||||
d errors=$(cat errors.log)
|
||||
body="Testing images finish with some errors. $errors"
|
||||
curl -X 'POST' "$URL/api/v1/repos/$REPO/image-forge/issues/$issueid/comments?token=$T" -H 'accept: application/json' -H 'Content-Type: application/json' -d "{ \"body\": \"$body\" }" -s
|
||||
curl -X 'POST' "$URL/api/v1/repos/$REPO/gitea-image-forge/issues/$issueid/comments?token=$T" -H 'accept: application/json' -H 'Content-Type: application/json' -d "{ \"body\": \"$body\" }" -s
|
||||
echo "notification about test error is sent to issue $issueid"
|
||||
env:
|
||||
T: ${{ secrets.TOKEN }}
|
||||
BR: ${{ needs.build-process.outputs.branch }}
|
||||
URL: ${{ gitea.server_url }}
|
||||
REPO: ${{ needs.build-process.outputs.repo }}
|
||||
push-process:
|
||||
needs: [build-process, test-process]
|
||||
if: ${{ needs.test-process.outputs.testres == 'success' && secrets.PUSH_REPO != '' }}
|
||||
runs-on: alt-p10
|
||||
steps:
|
||||
- name: Update apt
|
||||
uses: actions/init-alt-env@v1
|
||||
- name: Install reqier-s
|
||||
run: |
|
||||
echo "apt-get install -y skopeo jq"
|
||||
apt-get install -y skopeo jq
|
||||
- name: Get branch and tags to push
|
||||
run: |
|
||||
echo "PUSH_BRANCH=$BR" >> ${GITHUB_ENV}
|
||||
images=$()
|
||||
echo "PUSH_IMAGES=$images" >> ${GITHUB_ENV}
|
||||
if [[ $BR == 'p10' ]]; then echo "PUSH_TAGS=latest" >> ${GITHUB_ENV}; fi
|
||||
env:
|
||||
BR: ${{ needs.build-process.outputs.branch }}
|
||||
- name: Get branch (only for c*N branches)
|
||||
if: ${{ contains(github.ref_name, 'c10f2') }}
|
||||
run: |
|
||||
newbr=$(skopeo list-tags docker://$URL/$REPO/$BR/base/alt | jq '.Tags.[]' -r 2> /dev/null | sort | grep -m 1 c 2> /dev/null)
|
||||
echo "PUSH_BRANCH=$newbr" >> ${GITHUB_ENV}
|
||||
env:
|
||||
BR: ${{ needs.build-process.outputs.branch }}
|
||||
ORG: ${{ needs.build-process.outputs.org }}
|
||||
URL: ${{ needs.build-process.outputs.url }}
|
||||
REPO: ${{ needs.build-process.outputs.repo }}
|
||||
- name: Run skopeo action
|
||||
if: ${{ env.PUSH_BRANCH == needs.build-process.outputs.branch }}
|
||||
uses: actions/skopeo-copy@v1
|
||||
with:
|
||||
source: ${{ needs.build-process.outputs.url }/${{ needs.build-process.outputs.repo }}/${{ needs.build-process.outputs.branch }}/${{ needs.build-process.outputs.org }}
|
||||
source-proto: docker://
|
||||
dest: ${{ secrets.PUSH_REPO }}/${{ needs.build-process.outputs.branch }}
|
||||
dest-proto: docker://
|
||||
dest-login: ${{ secrets.PUSH_USER }}
|
||||
dest-pass: ${{ secrets.PUSH_PASS }}
|
||||
tags: ${{ env.PUSH_TAGS }}
|
||||
last-ver-tags: true
|
||||
images: ${{ env.PUSH_IMAGES }}
|
||||
args: -a
|
||||
|
21
.gitea/workflows/wf_public.yaml
Normal file
21
.gitea/workflows/wf_public.yaml
Normal file
@ -0,0 +1,21 @@
|
||||
name: 'Reusable test job'
|
||||
description: 'Test for images'
|
||||
|
||||
outputs:
|
||||
result:
|
||||
description: "Result of test (success|failure)"
|
||||
value: ${{ jobs.example_job.outputs.output1 }}
|
||||
inputs:
|
||||
image: string
|
||||
branch: string
|
||||
url: string
|
||||
repo: string
|
||||
|
||||
runs:
|
||||
using: 'composite'
|
||||
steps:
|
||||
- name: Install requires
|
||||
run: |
|
||||
echo "apt-get install -y skopeo jq"
|
||||
apt-get install -y skopeo jq
|
||||
- name: Scopeo copy
|
6
build.py
6
build.py
@ -230,7 +230,7 @@ class DockerBuilder:
|
||||
) -> str:
|
||||
if self.registry:
|
||||
registry = self.registry.rstrip("/") + "/"
|
||||
alt_image = "alt/alt"
|
||||
alt_image = "base/alt"
|
||||
else:
|
||||
registry = ""
|
||||
alt_image = "alt"
|
||||
@ -307,7 +307,7 @@ class DockerBuilder:
|
||||
f"{from_image['organization']}/{from_image['name']}"
|
||||
)
|
||||
elif distrolessfile.exists():
|
||||
requires.add("alt/distroless-builder")
|
||||
requires.add("base/distroless-builder")
|
||||
raw_from = self.distrolesses[canonical_name].raw_from
|
||||
from_ = self.render_template(raw_from, self.organization)
|
||||
if match := re.match(self.image_re, from_):
|
||||
@ -345,7 +345,7 @@ class DockerBuilder:
|
||||
def distroless_build(self, image: Image, arches):
|
||||
def distroless_build_arch(arch, manifest):
|
||||
distroless_builder = self.render_full_tag(
|
||||
Image("alt/distroless-builder"), self.branch
|
||||
Image("base/distroless-builder"), self.branch
|
||||
)
|
||||
distroless = self.distrolesses[image.canonical_name]
|
||||
distroless.render_arch_branch(arch, self.branch)
|
||||
|
@ -1,4 +1,4 @@
|
||||
FROM {{ registry }}{{ organization }}/buildpack-deps-curl:{{ branch }}
|
||||
FROM {{ registry }}base/buildpack-deps-curl:{{ branch }}
|
||||
|
||||
MAINTAINER alt-cloud
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
FROM {{ registry }}{{ organization }}/buildpack-deps-scm:{{ branch }}
|
||||
FROM {{ registry }}base/buildpack-deps-scm:{{ branch }}
|
||||
|
||||
MAINTAINER alt-cloud
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
FROM {{ registry }}{{ organization }}/base:{{ branch }}
|
||||
FROM {{ registry }}base/base:{{ branch }}
|
||||
|
||||
MAINTAINER alt-cloud
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
from = "{{ registry }}{{ organization }}/distroless-static:{{ branch }}"
|
||||
from = "{{ registry }}base/distroless-static:{{ branch }}"
|
||||
builder-install-packages = [
|
||||
"glibc-core",
|
||||
'{{if_branches(["p10"], "glibc-nss")}}',
|
||||
|
@ -1,4 +1,4 @@
|
||||
from = "{{ registry }}{{ organization }}/distroless-base:{{ branch }}"
|
||||
from = "{{ registry }}base/distroless-base:{{ branch }}"
|
||||
builder-install-packages = [
|
||||
"coreutils",
|
||||
"findutils",
|
||||
|
@ -1,3 +1,3 @@
|
||||
from = "{{ registry }}{{ organization }}/distroless-base:{{ branch }}"
|
||||
from = "{{ registry }}base/distroless-base:{{ branch }}"
|
||||
full-files = ["/usr/bin/gotop"]
|
||||
entrypoint = ["/usr/bin/gotop"]
|
||||
|
@ -1,3 +1,3 @@
|
||||
from = "{{ registry }}{{ organization }}/distroless-static:{{ branch }}"
|
||||
from = "{{ registry }}base/distroless-static:{{ branch }}"
|
||||
files = ["/bin/true"]
|
||||
cmd = ["/bin/true"]
|
||||
|
@ -1,4 +1,4 @@
|
||||
FROM {{ registry }}{{ organization }}/buildpack-deps:{{ branch }}
|
||||
FROM {{ registry }}base/buildpack-deps:{{ branch }}
|
||||
|
||||
MAINTAINER alt-cloud
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
FROM {{ registry }}{{ organization }}/base:{{ branch }}
|
||||
FROM {{ registry }}base/base:{{ branch }}
|
||||
|
||||
MAINTAINER alt-cloud
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
FROM {{ registry }}{{ organization }}/base:{{ branch }}
|
||||
FROM {{ registry }}base/base:{{ branch }}
|
||||
|
||||
MAINTAINER alt-cloud
|
||||
|
||||
|
Reference in New Issue
Block a user