diff --git a/.github/workflows/production.yml b/.github/workflows/production.yml index 66655aa..37a77a2 100644 --- a/.github/workflows/production.yml +++ b/.github/workflows/production.yml @@ -21,7 +21,7 @@ env: REGISTRY_GITHUB: ghcr.io REGISTRY_DOCKERHUB: docker.io IMAGE_NAME: appwrite/mcp - TAG: ${{ github.event.release.tag_name || github.sha }} + TAG: ${{ github.event.release.tag_name }} jobs: build: @@ -56,6 +56,9 @@ jobs: deploy: needs: build runs-on: ubuntu-latest + concurrency: + group: declarative-deploy + cancel-in-progress: false steps: - name: Get token for ${{ env.DECLARATIVE_REPOSITORY }} id: app-token @@ -73,16 +76,25 @@ jobs: token: ${{ steps.app-token.outputs.token }} - name: Update image tag - run: yq -i '.["mcp"].image.tag = strenv(TAG)' ${{ env.ENVIRONMENT }}/${{ env.PROJECT }}/fra1.yaml + run: yq -i '.["mcp"].image.tag = strenv(TAG)' ${{ env.ENVIRONMENT }}/${{ env.PROJECT }}/default.yaml - name: Commit and push run: | git config user.name "github-actions[bot]" git config user.email "github-actions[bot]@users.noreply.github.com" - git add ${{ env.ENVIRONMENT }}/${{ env.PROJECT }}/fra1.yaml + git add ${{ env.ENVIRONMENT }}/${{ env.PROJECT }}/default.yaml if git diff --cached --quiet; then echo "No changes to commit" - else - git commit -m "chore(${{ env.ENVIRONMENT }}): ${{ env.PROJECT }} image tag to ${{ env.TAG }}" - git push + exit 0 fi + git commit -m "chore(${{ env.ENVIRONMENT }}): ${{ env.PROJECT }} image tag to ${{ env.TAG }}" + for attempt in 1 2 3 4 5; do + if git push; then + echo "Pushed on attempt $attempt" + exit 0 + fi + echo "Push rejected (attempt $attempt), rebasing onto remote and retrying..." + git pull --rebase + done + echo "Failed to push after 5 attempts" + exit 1 diff --git a/.github/workflows/staging.yml b/.github/workflows/staging.yml index 7c92021..ca7ee79 100644 --- a/.github/workflows/staging.yml +++ b/.github/workflows/staging.yml @@ -57,6 +57,9 @@ jobs: deploy: needs: build runs-on: ubuntu-latest + concurrency: + group: declarative-deploy + cancel-in-progress: false steps: - name: Get token for ${{ env.DECLARATIVE_REPOSITORY }} id: app-token @@ -74,16 +77,25 @@ jobs: token: ${{ steps.app-token.outputs.token }} - name: Update image tag - run: yq -i '.["mcp"].image.tag = strenv(TAG)' ${{ env.ENVIRONMENT }}/${{ env.PROJECT }}/fra1.yaml + run: yq -i '.["mcp"].image.tag = strenv(TAG)' ${{ env.ENVIRONMENT }}/${{ env.PROJECT }}/default.yaml - name: Commit and push run: | git config user.name "github-actions[bot]" git config user.email "github-actions[bot]@users.noreply.github.com" - git add ${{ env.ENVIRONMENT }}/${{ env.PROJECT }}/fra1.yaml + git add ${{ env.ENVIRONMENT }}/${{ env.PROJECT }}/default.yaml if git diff --cached --quiet; then echo "No changes to commit" - else - git commit -m "chore(${{ env.ENVIRONMENT }}): ${{ env.PROJECT }} image tag to ${{ env.TAG }}" - git push + exit 0 fi + git commit -m "chore(${{ env.ENVIRONMENT }}): ${{ env.PROJECT }} image tag to ${{ env.TAG }}" + for attempt in 1 2 3 4 5; do + if git push; then + echo "Pushed on attempt $attempt" + exit 0 + fi + echo "Push rejected (attempt $attempt), rebasing onto remote and retrying..." + git pull --rebase + done + echo "Failed to push after 5 attempts" + exit 1