From c7c7022dffb7fa8cc80f3a0d9d7103a90eef4cf4 Mon Sep 17 00:00:00 2001 From: Fabio Date: Fri, 4 Apr 2025 10:39:05 -0300 Subject: [PATCH] Simplify push-to-branch step --- .drone.yml | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/.drone.yml b/.drone.yml index 2eed3f4..91d0dd0 100644 --- a/.drone.yml +++ b/.drone.yml @@ -47,14 +47,11 @@ steps: - name: push-to-branch image: alpine/git commands: - # Set up the gh-pages branch - - git fetch origin gh-pages || echo "gh-pages not found, will create it" - - git checkout gh-pages || git checkout -b gh-pages - # Copy new chart artifacts - - mkdir -p charts/dist - - cp -r $DRONE_WORKSPACE/charts/dist/* charts/dist/ - # Commit changes + # Check if gh-pages exists remotely, fetch it if it does, otherwise create it + - git ls-remote --heads origin gh-pages | grep -q gh-pages && git fetch origin gh-pages && git checkout gh-pages || git checkout -b gh-pages + # Stage the charts/dist directory (already in the working directory) - git add charts/dist/* + # Commit changes - git commit -m "Update Helm charts from commit ${DRONE_COMMIT}" || echo "No changes to commit" # Push with API key in URL and check for failure - git push https://x:${GITEA_API_KEY}@git.interlegis.leg.br/seit/rancher-charts.git HEAD:gh-pages --force || { echo "Git push failed"; exit 1; }