first commit
Some checks are pending
Build and Push Docker Image / build-and-push (push) Waiting to run
Some checks are pending
Build and Push Docker Image / build-and-push (push) Waiting to run
This commit is contained in:
54
.gitea/workflows/docker.yaml
Normal file
54
.gitea/workflows/docker.yaml
Normal 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
|
||||
Reference in New Issue
Block a user