feat(ci): use nfc gitlab-ci project for ci

!3
This commit is contained in:
2023-05-13 14:33:24 +09:30
parent 3f6e77b0ed
commit 3e7094c243

View File

@ -2,151 +2,58 @@
variables:
GIT_SUBMODULE_STRATEGY: recursive
MY_PROJECT_ID: "45741845"
GIT_SYNC_URL: "https://$GITHUB_USERNAME_ROBOT:$GITHUB_TOKEN_ROBOT@github.com/NoFussComputing/execution_environment.git"
DOCKER_IMAGE_BUILD_TARGET_PLATFORMS: "linux/amd64,linux/arm64,linux/arm/v7"
DOCKER_IMAGE_PUBLISH_NAME: 'ansible-ee'
DOCKER_IMAGE_PUBLISH_REGISTRY: docker.io/nofusscomputing
DOCKER_IMAGE_PUBLISH_URL: https://hub.docker.com/r/nofusscomputing/$DOCKER_IMAGE_PUBLISH_NAME
stages:
- validation
- build
- prepare
- test
- release
- sync
- publish
include:
- project: nofusscomputing/projects/gitlab-ci
ref: 36ce0b0b76e6769c7a2e0d4ea0f3fcd2cc2d6bb1
ref: restructure
file:
- conventional_commits/.gitlab-ci.yml
- gitlab_release/.gitlab-ci.yml
- git_push_mirror/.gitlab-ci.yml
- .gitlab-ci_common.yaml
- type/docker-image.gitlab-ci.yaml
#- template: Jobs/Container-Scanning.gitlab-ci.yml # see https://gitlab.com/gitlab-org/gitlab/-/issues/381665
Docker Container:
Build/Cache Python Packages:
stage: build
image: docker:latest
image: nofusscomputing/docker-buildx-qemu:dev
services:
- docker:19.03.12-dind
#- docker:latest-dind
- name: docker:23-dind
entrypoint: ["env", "-u", "DOCKER_HOST"]
command: ["dockerd-entrypoint.sh"]
variables:
IMAGE_NAME: ansible-ee
DOCKER_HOST: tcp://docker:2375/
DOCKER_DRIVER: overlay2
DOCKER_TLS_CERTDIR: ""
before_script:
- docker info
# - docker login $CI_REGISTRY -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- apk update
- apk add --update --no-cache python3 git && ln -sf python3 /usr/bin/python
- python3 -m ensurepip
#- pip3 install -r gitlab-ci/gitlab_release/requirements.txt
#- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- pip3 install setuptools wheel
- pip3 install commitizen==2.21.0 # version specified so current build works.
- pip3 install gitlab-ci/gitlab_release/python-module/cz_nfc/.
- update-binfmts --enable # Important: Ensures execution of other binary formats is enabled in the kernel
- docker buildx create --driver=docker-container --driver-opt image=moby/buildkit:v0.11.6 --use
- docker buildx inspect --bootstrap
script: |
docker build . \
--label org.opencontainers.image.created="$(date '+%Y-%m-%d %H:%M:%S%:z')" \
--label org.opencontainers.image.documentation="$CI_PROJECT_URL" \
--label org.opencontainers.image.source="$CI_PROJECT_URL" \
--label org.opencontainers.image.url="$CI_PROJECT_URL/-/releases/$(cz -n cz_nfc version --project)" \
--label org.opencontainers.image.version="$(cz -n cz_nfc version --project)" \
--label org.opencontainers.image.revision="$CI_COMMIT_SHA" \
--no-cache \
--tag $CI_REGISTRY_IMAGE/$IMAGE_NAME:$CI_COMMIT_SHA;
docker image inspect $CI_REGISTRY_IMAGE/$IMAGE_NAME:$CI_COMMIT_SHA;
docker push $CI_REGISTRY_IMAGE/$IMAGE_NAME:$CI_COMMIT_SHA;
#allow_failure: true
docker buildx build \
--file dockerfile-build_cache \
--platform=$DOCKER_IMAGE_BUILD_TARGET_PLATFORMS . \
--build-arg CI_JOB_TOKEN=$CI_JOB_TOKEN \
--build-arg CI_API_V4_URL=$CI_API_V4_URL \
--build-arg CI_PROJECT_ID=$CI_PROJECT_ID
rules:
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
when: never
- if: $CI_COMMIT_TAG
when: on_success
# - if: '$CI_COMMIT_BRANCH == "development" && $CI_COMMIT_TITLE =~ /Merge branch.*/'
# when: on_success
- if: '$CI_COMMIT_BRANCH != "master"'
allow_failure: true
when: manual
- when: never
Docker Hub:
stage: publish
image: docker:latest
services:
- docker:19.03.12-dind
#- docker:latest-dind
variables:
IMAGE_NAME: ansible-ee
before_script:
- export
- docker login $CI_REGISTRY -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD
- docker pull $CI_REGISTRY_IMAGE/$IMAGE_NAME:$CI_COMMIT_SHA
- docker logout $CI_REGISTRY
script:
# - Release_TAG=$(cat $CI_PROJECT_DIR/dist/version)
- docker login docker.io -u $NFC_DOCKERHUB_USERNAME -p $NFC_DOCKERHUB_TOKEN
# - if [ "m$(echo $CI_BUILD_REF_NAME | grep rc)" == "m$CI_BUILD_REF_NAME" ]; then Branch_TAG=dev; else Branch_TAG=stable; fi
- echo Branch tag is $Branch_TAG
- docker image ls
- |
DH_LATEST_TAG=dev
if [ "0$CI_COMMIT_BRANCH" == "0development" ]; then
DH_LATEST_TAG=dev
elif [ "0$CI_COMMIT_TAG" != "0" ] ; then
if [ "0$CI_COMMIT_TAG" == *"rc"* ]; then
DH_LATEST_TAG=dev
else
DH_LATEST_TAG=latest
fi
docker image tag $CI_REGISTRY_IMAGE/$IMAGE_NAME:$CI_COMMIT_SHA nofusscomputing/$IMAGE_NAME:$CI_COMMIT_TAG;
docker image ls;
docker push nofusscomputing/$IMAGE_NAME:$CI_COMMIT_TAG;
fi
if [ "0$DH_LATEST_TAG" != "0" ]; then
docker image tag $CI_REGISTRY_IMAGE/$IMAGE_NAME:$CI_COMMIT_SHA nofusscomputing/$IMAGE_NAME:$DH_LATEST_TAG;
docker image ls;
docker push nofusscomputing/$IMAGE_NAME:$DH_LATEST_TAG;
fi
needs: [ "Docker Container" ]
environment:
name: DockerHub
url: https://hub.docker.com/r/nofusscomputing/$IMAGE_NAME
rules:
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
when: never
- if: $CI_COMMIT_TAG
when: on_success
# - if: '$CI_COMMIT_BRANCH == "development" && $CI_COMMIT_TITLE =~ /Merge branch.*/'
# when: on_success
- if: '$CI_COMMIT_BRANCH != "master"'
allow_failure: true
when: manual
- when: never
Github (Push --mirror):
variables:
GIT_SYNC_URL: "https://$GITHUB_USERNAME_ROBOT:$GITHUB_TOKEN_ROBOT@github.com/NoFussComputing/execution_environment.git"
extends:
- .git_push_mirror