37 lines
1.3 KiB
YAML
37 lines
1.3 KiB
YAML
# .gitea/workflows/build.yaml
|
|
name: Build and Push Docker Image
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- 'main'
|
|
- 'master'
|
|
|
|
jobs:
|
|
build-and-push:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
|
|
# Log in directly - senza QEMU e Buildx
|
|
- name: Log in to Gitea Container Registry
|
|
run: |
|
|
echo "${{ secrets.GITEA_TOKEN }}" | docker login \
|
|
-u "${{ secrets.GITEA_USERNAME }}" \
|
|
--password-stdin \
|
|
gitea.example.com
|
|
|
|
- name: Extract metadata
|
|
id: meta
|
|
run: |
|
|
echo "REPO_NAME=$(echo ${GITHUB_REPOSITORY} | awk -F'/' '{print $2}')" >> $GITHUB_OUTPUT
|
|
echo "SHORT_SHA=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
|
|
|
|
- name: Build and push Docker image
|
|
run: |
|
|
docker build -t gitea.example.com/${{ github.repository_owner }}/${{ steps.meta.outputs.REPO_NAME }}:latest .
|
|
docker tag gitea.example.com/${{ github.repository_owner }}/${{ steps.meta.outputs.REPO_NAME }}:latest \
|
|
gitea.example.com/${{ github.repository_owner }}/${{ steps.meta.outputs.REPO_NAME }}:${{ steps.meta.outputs.SHORT_SHA }}
|
|
docker push gitea.example.com/${{ github.repository_owner }}/${{ steps.meta.outputs.REPO_NAME }} --all-tags
|