first commit
Some checks are pending
Build and Push Docker Image / build-and-push (push) Waiting to run

This commit is contained in:
MTimka
2026-05-13 11:31:18 -07:00
parent e16668665c
commit 0f9b7a24e6
7 changed files with 147 additions and 0 deletions

View File

@@ -0,0 +1,54 @@
name: Build and Push Docker Image
on:
push:
branches:
- main
env:
REGISTRY: repositry.talutasku.ee
IMAGE_NAME: my-python-app
jobs:
build-and-push:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- 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
uses: docker/build-push-action@v5
with:
context: .
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
- name: Update image tag file
run: |
echo "${{ steps.vars.outputs.sha }}" > k8s/image-tag.txt
- name: Commit and push image tag
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