github actions & environment files #2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Deploy to Production | ||
on: | ||
workflow_dispatch: | ||
inputs: | ||
tag: | ||
type: string | ||
description: The tag to deploy | ||
required: true | ||
env: | ||
KUBE_CONFIG: ${{ secrets.KUBE_CONFIG }} | ||
DOCKER_REGISTRY: your-registry | ||
DOCKER_IMAGE: your-app | ||
jobs: | ||
deploy: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Set up kubectl | ||
uses: azure/k8s-set-context@v1 | ||
with: | ||
kubeconfig: ${{ secrets.PRODUCTION_KUBE_CONFIG }} | ||
- name: Install Helm | ||
uses: azure/setup-helm@v3 | ||
with: | ||
version: 'v3.12.0' | ||
- name: Update image tag in values file | ||
run: | | ||
sed -i "s/tag: .*/tag: ${{ github.event.inputs.tag }}/" charts/portal/environments/production.yaml | ||
- name: Commit changes | ||
run: | | ||
git config --global user.name 'GitHub Actions' | ||
git config --global user.email '[email protected]' | ||
git add charts/portal/environments/production.yaml | ||
git commit -m "Update image tag to ${{ github.event.inputs.tag }}" | ||
git push | ||
- name: Deploy to production | ||
run: | | ||
helm upgrade portal portal -n portal -f portal/values.yaml -f portal/environments/production.yaml |