Skip to content

Update deployment.yaml #26

Update deployment.yaml

Update deployment.yaml #26

Workflow file for this run

name: CI/CD
on:
push:
branches:
- main
env:
DOCKERHUB_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKERHUB_KEY: ${{ secrets.DOCKER_KEY }}
IMAGE_NAME: oss_implementation_repo
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Set up Helm
uses: azure/setup-helm@v3
with:
version: v3.12.1
- uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Set up chart-testing
uses: helm/[email protected]
- name: Run chart-testing (list-changed)
id: list-changed
run: |
changed=$(ct list-changed --target-branch ${{ github.event.repository.default_branch }})
if [[ -n "$changed" ]]; then
echo "changed=true" >> "$GITHUB_OUTPUT"
fi
- name: Run chart-testing (lint)
if: steps.list-changed.outputs.changed == 'true'
run: ct lint --target-branch ${{ github.event.repository.default_branch }}
- name: Create kind cluster
if: steps.list-changed.outputs.changed == 'true'
uses: helm/[email protected]
- name: Run chart-testing (install)
if: steps.list-changed.outputs.changed == 'true'
run: ct install --target-branch ${{ github.event.repository.default_branch }}
build-and-push-docker-image:
runs-on: ubuntu-latest
needs: test
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Login to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ env.DOCKERHUB_USERNAME }}
password: ${{ env.DOCKERHUB_KEY }}
- name: Build Docker image
run: |
cd app
docker build -t ${{ env.DOCKERHUB_USERNAME }}/${{ env.IMAGE_NAME }}:${{ github.sha }} .
- name: Push Docker image
run: |
cd app
docker push ${{ env.DOCKERHUB_USERNAME }}/${{ env.IMAGE_NAME }}:${{ github.sha }}
deploy-to-dev:
environment: dev
runs-on: ubuntu-latest
needs: build-and-push-docker-image
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Update dev image
run: |
cd app/helm
sed -i 's|DEV_APP_VERSION:.*|DEV_APP_VERSION: '${{ github.sha }}'|' values.yaml
git config --global user.name 'GitHub Actions'
git config --global user.email '[email protected]'
git add values.yaml
git commit -m "Update DEV_APP_VERSION in values.yaml"
git push
deploy-to-staging:
environment: staging
runs-on: ubuntu-latest
needs: deploy-to-dev
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Update staging image
run: |
git pull
cd app/helm
sed -i 's|STAGING_APP_VERSION:.*|STAGING_APP_VERSION: '${{ github.sha }}'|' values.yaml
git config --global user.name 'GitHub Actions'
git config --global user.email '[email protected]'
git add values.yaml
git commit -m "Update STAGING_APP_VERSION in values.yaml"
git push
deploy-to-prod:
environment: prod
runs-on: ubuntu-latest
needs: deploy-to-staging
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Update prod image
run: |
git pull
cd app/helm
sed -i 's|PROD_APP_VERSION:.*|PROD_APP_VERSION: '${{ github.sha }}'|' values.yaml
git config --global user.name 'GitHub Actions'
git config --global user.email '[email protected]'
git add values.yaml
git commit -m "Update PROD_APP_VERSION in values.yaml"
git push