Git-sha is now set as docker image tag
This commit is contained in:
parent
37ea900325
commit
7a411a7148
@ -11,7 +11,7 @@ spec:
|
|||||||
- name: branch
|
- name: branch
|
||||||
value: main
|
value: main
|
||||||
- name: image
|
- name: image
|
||||||
value: marcin00.azurecr.io/user-microservice:{{workflow.uid}}
|
value: marcin00.azurecr.io/user-microservice
|
||||||
- name: registry_server
|
- name: registry_server
|
||||||
value: marcin00.azurecr.io
|
value: marcin00.azurecr.io
|
||||||
serviceAccountName: edu-agentpool
|
serviceAccountName: edu-agentpool
|
||||||
@ -36,10 +36,16 @@ spec:
|
|||||||
value: "{{workflow.parameters.repo}}"
|
value: "{{workflow.parameters.repo}}"
|
||||||
- name: branch
|
- name: branch
|
||||||
value: "{{workflow.parameters.branch}}"
|
value: "{{workflow.parameters.branch}}"
|
||||||
|
- - name: get-git-sha
|
||||||
|
template: get-git-sha
|
||||||
- - name: tests
|
- - name: tests
|
||||||
template: tests
|
template: tests
|
||||||
- - name: build-test-and-push-image
|
- - name: build-test-and-push-image
|
||||||
template: build-test-and-push-image
|
template: build-test-and-push-image
|
||||||
|
arguments:
|
||||||
|
parameters:
|
||||||
|
- name: git-sha
|
||||||
|
value: "{{steps.get-git-sha.outputs.parameters.git-sha}}"
|
||||||
|
|
||||||
# 📦 GIT CHECKOUT
|
# 📦 GIT CHECKOUT
|
||||||
- name: checkout
|
- name: checkout
|
||||||
@ -63,6 +69,23 @@ spec:
|
|||||||
- name: workspace
|
- name: workspace
|
||||||
mountPath: /workspace
|
mountPath: /workspace
|
||||||
|
|
||||||
|
# Get sha of the latest commit
|
||||||
|
- name: get-git-sha
|
||||||
|
script:
|
||||||
|
image: alpine/git
|
||||||
|
command: [sh]
|
||||||
|
workingDir: /workspace/repo
|
||||||
|
source: |
|
||||||
|
git rev-parse HEAD > /tmp/gitsha.txt
|
||||||
|
volumeMounts:
|
||||||
|
- name: workspace
|
||||||
|
mountPath: /workspace
|
||||||
|
outputs:
|
||||||
|
parameters:
|
||||||
|
- name: git-sha
|
||||||
|
valueFrom:
|
||||||
|
path: /tmp/gitsha.txt
|
||||||
|
|
||||||
# 🧪 PYTHON TESTS
|
# 🧪 PYTHON TESTS
|
||||||
- name: tests
|
- name: tests
|
||||||
script:
|
script:
|
||||||
@ -80,6 +103,9 @@ spec:
|
|||||||
|
|
||||||
# 🐳 BUILDS AND GOSS TESTS
|
# 🐳 BUILDS AND GOSS TESTS
|
||||||
- name: build-test-and-push-image
|
- name: build-test-and-push-image
|
||||||
|
inputs:
|
||||||
|
parameters:
|
||||||
|
- name: git-sha
|
||||||
container:
|
container:
|
||||||
image: docker:dind
|
image: docker:dind
|
||||||
command: [sh, -c]
|
command: [sh, -c]
|
||||||
@ -88,7 +114,8 @@ spec:
|
|||||||
- |
|
- |
|
||||||
dockerd-entrypoint.sh &
|
dockerd-entrypoint.sh &
|
||||||
sleep 3
|
sleep 3
|
||||||
docker build -t {{workflow.parameters.image}} .
|
DOCKER_IMAGE={{workflow.parameters.image}}:{{inputs.parameters.git-sha}}
|
||||||
|
docker build -t $DOCKER_IMAGE .
|
||||||
|
|
||||||
apk add --no-cache bash
|
apk add --no-cache bash
|
||||||
|
|
||||||
@ -99,13 +126,13 @@ spec:
|
|||||||
export GOSS_OPTS="-f junit"
|
export GOSS_OPTS="-f junit"
|
||||||
export GOSS_PATH=./goss
|
export GOSS_PATH=./goss
|
||||||
export GOSS_SLEEP=3
|
export GOSS_SLEEP=3
|
||||||
./dgoss run -e SQLALCHEMY_DATABASE_URI=sqlite:///:memory: {{workflow.parameters.image}} > /workspace/goss_junit.xml
|
./dgoss run -e SQLALCHEMY_DATABASE_URI=sqlite:///:memory: $DOCKER_IMAGE > /workspace/goss_junit.xml
|
||||||
|
|
||||||
echo "===> Logging into ACR"
|
echo "===> Logging into ACR"
|
||||||
echo "$ACR_PASSWORD" | docker login {{workflow.parameters.registry_server}} -u $ACR_USERNAME --password-stdin
|
echo "$ACR_PASSWORD" | docker login {{workflow.parameters.registry_server}} -u $ACR_USERNAME --password-stdin
|
||||||
|
|
||||||
echo "===> Pushing image to ACR"
|
echo "===> Pushing image to ACR"
|
||||||
docker push {{workflow.parameters.image}}
|
docker push $DOCKER_IMAGE
|
||||||
env:
|
env:
|
||||||
- name: ACR_USERNAME
|
- name: ACR_USERNAME
|
||||||
valueFrom:
|
valueFrom:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user