Skip to content

Commit

Permalink
Merge pull request #156 from amisskii/buildah
Browse files Browse the repository at this point in the history
Buildah
  • Loading branch information
amisskii authored Mar 12, 2024
2 parents 7b68a79 + de6e711 commit d377742
Showing 1 changed file with 83 additions and 9 deletions.
92 changes: 83 additions & 9 deletions .tekton/create-ci-image-pipelinerun.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
apiVersion: tekton.dev/v1beta1
apiVersion: tekton.dev/v1
kind: PipelineRun
metadata:
name: create-push-ci-image
Expand All @@ -8,6 +8,9 @@ metadata:
"Dockerfile.CI".pathChanged() && ( event == "push" || event == "pull_request" )
pipelinesascode.tekton.dev/max-keep-runs: "5"
spec:
taskRunSpecs:
- pipelineTaskName: skopeo-copy-push
serviceAccountName: skopeo-copy-quay-creds
params:
- name: repo_url
value: "{{ repo_url }}"
Expand Down Expand Up @@ -39,6 +42,7 @@ spec:
results:
- name: image-name
- name: image-name-timestamp
- name: repository
steps:
- name: generate-image-name
image: quay.io/openshift-pipeline/ci
Expand All @@ -47,21 +51,26 @@ spec:
BRANCH_NAME={{ target_branch }}
IMAGE_NAME=""
IMAGE_NAME_TIMESTAMP=""
REPOSITORY=""
TIMESTAMP=$(date +"%y%m%d%H%M")
if [ "$BRANCH_NAME" == "master" ]; then
if [ {{ event_type }} == "pull_request" ]; then
IMAGE_NAME="image-registry.openshift-image-registry.svc:5000/pipelines-ci/ci:latest"
IMAGE_NAME_TIMESTAMP="image-registry.openshift-image-registry.svc:5000/pipelines-ci/ci:5.0-$TIMESTAMP"
REPOSITORY="image-registry"
else
IMAGE_NAME="quay.io/openshift-pipeline/ci:latest"
IMAGE_NAME_TIMESTAMP="quay.io/openshift-pipeline/ci:5.0-$TIMESTAMP"
IMAGE_NAME="quay.io/openshift-pipeline/chainstest:latest"
IMAGE_NAME_TIMESTAMP="quay.io/openshift-pipeline/chainstest:5.0-$TIMESTAMP"
REPOSITORY="quay.io"
fi
elif [[ "$BRANCH_NAME" == release-* ]]; then
if [ {{ event_type }} == "pull_request" ]; then
IMAGE_NAME="image-registry.openshift-image-registry.svc:5000/pipelines-ci/ci:${BRANCH_NAME#release-}"
REPOSITORY="image-registry"
else
IMAGE_NAME="quay.io/openshift-pipeline/ci:${BRANCH_NAME#release-}"
REPOSITORY="quay.io"
fi
IMAGE_NAME_TIMESTAMP="$IMAGE_NAME-$TIMESTAMP"
else
Expand All @@ -71,9 +80,10 @@ spec:
echo -n "$IMAGE_NAME" | tee $(results.image-name.path)
echo -n "$IMAGE_NAME_TIMESTAMP" | tee $(results.image-name-timestamp.path)
echo -n "$REPOSITORY" | tee $(results.repository.path)
runAfter:
- fetch-repository
- name: buildah
- name: buildah-push
taskRef:
kind: ClusterTask
name: buildah
Expand All @@ -89,7 +99,12 @@ spec:
workspace: source
- name: dockerconfig
workspace: dockerconfig
- name: skopeo-copy
when:
- input: "quay.io"
operator: in
values:
- "$(tasks.generate-image-name.results.repository)"
- name: skopeo-copy-push
taskRef:
kind: ClusterTask
name: skopeo-copy
Expand All @@ -102,9 +117,64 @@ spec:
- name: destImageURL
value: docker://$(tasks.generate-image-name.results.image-name-timestamp)
runAfter:
- buildah
- buildah-push
when:
- input: "quay.io"
operator: in
values:
- "$(tasks.generate-image-name.results.repository)"
- name: buildah-pull-request
taskRef:
kind: ClusterTask
name: buildah
params:
- name: IMAGE
value: $(tasks.generate-image-name.results.image-name)
- name: DOCKERFILE
value: ./Dockerfile.CI
runAfter:
- generate-image-name
workspaces:
- name: source
workspace: source
- name: skopeo-copy-pull-request
taskRef:
kind: ClusterTask
name: skopeo-copy
workspaces:
- name: images-url
workspace: images-url
params:
- name: srcImageURL
value: docker://$(tasks.generate-image-name.results.image-name)
- name: destImageURL
value: docker://$(tasks.generate-image-name.results.image-name-timestamp)
runAfter:
- buildah-pull-request
finally:
- name: send-slack-notification
- name: send-slack-notification-request
taskRef:
resolver: cluster
params:
- name: kind
value: task
- name: name
value: send-slack-notification
- name: namespace
value: pipelines-ci
params:
- name: MESSAGE
value: "<icon> Uploading IS image *<run_status>* <icon> <<logs_url>|logs>"
when:
- input: $(tasks.skopeo-copy-pull-request.status)
operator: in
values: ["Failed", "None"]
- input: "image-registry"
operator: in
values:
- "$(tasks.generate-image-name.results.repository)"

- name: send-slack-notification-push
taskRef:
resolver: cluster
params:
Expand All @@ -118,9 +188,13 @@ spec:
- name: MESSAGE
value: "<icon> Uploading CI image *<run_status>* <icon> <<logs_url>|logs>"
when:
- input: $(tasks.skopeo-copy.status)
- input: $(tasks.skopeo-copy-push.status)
operator: in
values: ["Failed", "None"]
- input: "quay.io"
operator: in
values:
- "$(tasks.generate-image-name.results.repository)"

workspaces:
- name: dockerconfig
Expand All @@ -135,4 +209,4 @@ spec:
- ReadWriteOnce
resources:
requests:
storage: 1Gi
storage: 1Gi

0 comments on commit d377742

Please sign in to comment.