Skip to content

Commit

Permalink
documentation: Add Gitlab CI example to README
Browse files Browse the repository at this point in the history
  • Loading branch information
jlenon7 committed Oct 28, 2021
1 parent 445f88d commit f0c902c
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 1 deletion.
53 changes: 53 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,4 +106,57 @@ spec:
---
#### Using templating in a Gitlab CI pipeline
```yaml
services:
- docker:dind

variables:
IMAGE_TAG: jlenon7/your-service-name-here:$CI_COMMIT_SHA
IMAGE_LATEST: jlenon7/your-service-name-here:latest

stages:
- test
- build
- deploy

Verify lint and run tests:
stage: test
script:
- npm install
- npm run lint:fix
- npm run test
only:
- merge_requests

Build and push image to Dockerhub:
image: docker:latest
stage: build
script:
- echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
- docker pull $IMAGE_LATEST || true
- docker build --cache-from $IMAGE_LATEST -t $IMAGE_TAG -t $IMAGE_LATEST .
- docker push $IMAGE_TAG
- docker push $IMAGE_LATEST
only:
- main

Deploy image to K8S Cluster:
image: jlenon7/gitlab-deploy:latest
stage: deploy
script:
- aws configure set aws_access_key_id $AWS_ACCESS_KEY_ID
- aws configure set aws_secret_access_key $AWS_SECRET_ACCESS_KEY
- aws configure set region $AWS_DEFAULT_REGION
- aws eks --region us-east-1 update-kubeconfig --name eks-us-east-1-production
- templating generate ./manifest/templates --set IMAGE_TAG=$IMAGE_TAG
- kubectl apply -f ./manifest
needs: ["Build and push image to Dockerhub"]
only:
- main
```
---
Made with 🖤 by [jlenon7](https://github.com/jlenon7) :wave:
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@jlenon7/templating",
"version": "1.0.4",
"version": "1.0.5",
"description": "",
"license": "MIT",
"author": "João Lenon",
Expand Down

0 comments on commit f0c902c

Please sign in to comment.