This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
name: Build and Push Docker Image
|
||||
name: Build and Deploy
|
||||
|
||||
on:
|
||||
push:
|
||||
@@ -6,11 +6,11 @@ on:
|
||||
- main
|
||||
|
||||
env:
|
||||
REGISTRY: repositry.talutasku.ee
|
||||
IMAGE_NAME: my-python-app
|
||||
APP_IMAGE: my-python-app
|
||||
OPERATOR_IMAGE: configmap-operator
|
||||
|
||||
jobs:
|
||||
build-and-push:
|
||||
build-and-deploy:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout code
|
||||
@@ -19,36 +19,43 @@ jobs:
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
- name: Log in to registry
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
registry: ${{ env.REGISTRY }}
|
||||
username: ${{ secrets.REGISTRY_USERNAME }}
|
||||
password: ${{ secrets.REGISTRY_PASSWORD }}
|
||||
|
||||
- name: Extract git SHA
|
||||
id: vars
|
||||
run: echo "sha=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Build and push Docker image
|
||||
- name: Build app image
|
||||
uses: docker/build-push-action@v5
|
||||
with:
|
||||
context: .
|
||||
file: ./Dockerfile
|
||||
push: true
|
||||
tags: |
|
||||
${{ env.REGISTRY }}/v2/${{ env.IMAGE_NAME }}:${{ steps.vars.outputs.sha }}
|
||||
${{ env.REGISTRY }}/v2/${{ env.IMAGE_NAME }}:latest
|
||||
cache-from: type=gha
|
||||
cache-to: type=gha,mode=max
|
||||
repositry.talutasku.ee/v2/my-python-app:${{ steps.vars.outputs.sha }}
|
||||
repositry.talutasku.ee/v2/my-python-app:latest
|
||||
|
||||
- name: Update image tag file
|
||||
run: |
|
||||
echo "${{ steps.vars.outputs.sha }}" > k8s/image-tag.txt
|
||||
- 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: Commit and push image tag
|
||||
- name: Set up kubectl
|
||||
uses: azure/setup-kubectl@v4
|
||||
with:
|
||||
version: 'latest'
|
||||
|
||||
- name: Configure kubectl
|
||||
run: |
|
||||
git config --local user.email "gitea-ci@example.com"
|
||||
git config --local user.name "Gitea CI"
|
||||
git add k8s/image-tag.txt
|
||||
git commit -m "Update image tag to ${{ steps.vars.outputs.sha }}" || exit 0
|
||||
git push
|
||||
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 }}"}}'
|
||||
Reference in New Issue
Block a user