Skip to content
Snippets Groups Projects
Commit 8bc90a06 authored by Joe Burnett's avatar Joe Burnett
Browse files

Pipeline with test, build, e2e and deploy

parent f493b62e
No related branches found
No related tags found
No related merge requests found
Pipeline #1092891060 passed
.local/
step-results.json
variables:
IMAGE_TAG: $CI_REGISTRY_IMAGE:pipeline-$CI_PIPELINE_ID
stages:
- test
- build
- e2e
- deploy
go-test:
stage: test
image: golang:1.21
script:
- go test ./...
docker-build:
stage: build
image: docker:20.10.16
services:
- docker:20.10.16-dind
script:
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- docker build -t $IMAGE_TAG .
- docker push $IMAGE_TAG
run-e2e:
stage: e2e
image: $IMAGE_TAG
script:
- /step-runner ci
variables:
STEPS: |
type: steps
steps:
- name: hello-world
step: https+git://gitlab.com/gitlab-org/ci-cd/runner-tools/step-runner-e2e-test-project
inputs:
echo: ${CI_PIPELINE_ID}
artifacts:
paths:
- step-results.json
verify-e2e:
stage: e2e
needs: ["run-e2e"]
script:
- apt update && apt install -y jq
- if [[ $(jq -r '.children_step_results[0].outputs.echo' step-results.json) != $CI_PIPELINE_ID ]]; then exit 1 ; fi
docker-push:
stage: deploy
rules:
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
image: docker:20.10.16
services:
- docker:20.10.16-dind
script:
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- docker pull $IMAGE_TAG
- docker tag $IMAGE_TAG $CI_REGISTRY_IMAGE:v0
- docker push $CI_REGISTRY_IMAGE:v0
FROM golang:1.21
WORKDIR /app
COPY go.mod go.sum ./
RUN go mod download
COPY . ./
RUN CGO_ENABLED=0 GOOS=linux go build -o /step-runner
CMD ["/step-runner"]
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment