61 lines
1.6 KiB
YAML
61 lines
1.6 KiB
YAML
name: Build and Deploy
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
|
|
env:
|
|
APP_IMAGE: my-python-app
|
|
OPERATOR_IMAGE: configmap-operator
|
|
|
|
jobs:
|
|
build-and-deploy:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v3
|
|
|
|
- name: Extract git SHA
|
|
id: vars
|
|
run: echo "sha=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
|
|
|
|
- name: Build app image
|
|
uses: docker/build-push-action@v5
|
|
with:
|
|
context: .
|
|
file: ./Dockerfile
|
|
push: true
|
|
tags: |
|
|
repositry.talutasku.ee/v2/my-python-app:${{ steps.vars.outputs.sha }}
|
|
repositry.talutasku.ee/v2/my-python-app:latest
|
|
|
|
- name: Build operator image
|
|
uses: docker/build-push-action@v5
|
|
with:
|
|
context: ./operator
|
|
file: ./operator/Dockerfile
|
|
push: true
|
|
tags: |
|
|
repositry.talutasku.ee/v2/configmap-operator:${{ steps.vars.outputs.sha }}
|
|
repositry.talutasku.ee/v2/configmap-operator:latest
|
|
|
|
- name: Set up kubectl
|
|
uses: azure/setup-kubectl@v4
|
|
with:
|
|
version: 'latest'
|
|
|
|
- name: Configure kubectl
|
|
run: |
|
|
echo "${{ secrets.KUBE_CONFIG }}" | base64 -d > kubeconfig
|
|
echo "KUBECONFIG=$(pwd)/kubeconfig" >> $GITHUB_ENV
|
|
|
|
- name: Patch ConfigMap
|
|
run: |
|
|
kubectl patch configmap python-app-config \
|
|
--namespace default \
|
|
--type merge \
|
|
--patch '{"data":{"IMAGE_TAG":"${{ steps.vars.outputs.sha }}"}}' |