81 lines
2.6 KiB
YAML
81 lines
2.6 KiB
YAML
name: Build
|
|
on:
|
|
push:
|
|
branches: [main, develop]
|
|
pull_request:
|
|
branches: [main]
|
|
tag:
|
|
- 'v*'
|
|
jobs:
|
|
build-and-push-image:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0 # Important pour récupérer tout l'historique Git
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v3
|
|
with:
|
|
driver-opts: |
|
|
network=host
|
|
buildkitd-config-inline: |
|
|
# La configuration BuildKit va ici
|
|
debug = true
|
|
[registry."harbor.bv.stef.lan"]
|
|
http = false
|
|
insecure = true
|
|
[[registry."harbor.bv.stef.lan".tls]]
|
|
ca = ["/etc/ssl/certs/zen-ca.pem"]
|
|
cert = []
|
|
key = []
|
|
|
|
|
|
- name: Log in to registry
|
|
uses: docker/login-action@v3
|
|
with:
|
|
registry: harbor.bv.stef.lan
|
|
username: ${{ secrets.HARBOR_USERNAME }}
|
|
password: ${{ secrets.HARBOR_PASSWORD }}
|
|
|
|
- name: Debug Gitea variables
|
|
run: |
|
|
echo "GITEA_REF: ${GITEA_REF}"
|
|
echo "GITEA_SHA: ${GITEA_SHA}"
|
|
echo "All env variables:"
|
|
env | grep -i gitea
|
|
|
|
- name: Generate Docker tags from Gitea context
|
|
id: docker_tags
|
|
run: |
|
|
# Récupérer le SHA court du commit
|
|
SHORT_SHA=$(git rev-parse --short HEAD)
|
|
|
|
# Pour les tags Git (si l'événement est un tag)
|
|
if [[ "${GITEA_REF}" == refs/tags/* ]]; then
|
|
TAG_NAME=${GITEA_REF#refs/tags/}
|
|
echo "TAGS=gitea.bv.stef.lan/stef/pki-manager:${TAG_NAME}" >> $GITHUB_OUTPUT
|
|
echo "TAGS=gitea.bv.stef.lan/stef/pki-manager:latest" >> $GITHUB_OUTPUT
|
|
else
|
|
# Pour les commits normaux
|
|
echo "TAGS=gitea.bv.stef.lan/stef/pki-manager:${SHORT_SHA}" >> $GITHUB_OUTPUT
|
|
echo "TAGS=gitea.bv.stef.lan/stef/pki-manager:latest" >> $GITHUB_OUTPUT
|
|
fi
|
|
|
|
echo "Generated tags will be:"
|
|
echo "${{ steps.docker_tags.outputs.TAGS }}"
|
|
|
|
- name: Build and push image
|
|
uses: docker/build-push-action@v6
|
|
with:
|
|
context: . # UTILISE LE CONTEXTE LOCAL, PAS L'URL GIT
|
|
push: ${{ github.event_name != 'pull_request' }}
|
|
tags: |
|
|
harbor.bv.stef.lan/library/pki-manager:test
|
|
cache-from: type=gha
|
|
cache-to: type=gha,mode=max
|
|
provenance: false # Peut simplifier le débogage initialement
|
|
build-args: |
|
|
BUILDKIT_CONTEXT_KEEP_GIT_DIR=1
|