AutoGPT is the vision of accessible AI for everyone, to use and to build on. Our mission is to provide the tools, so that you can focus on what matters.
Clean up CI git logic
Reinier van der Leer84e58051faa0
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.ymlindex 8793b203d6..a9656fc161 100644--- a/.github/workflows/ci.yml+++ b/.github/workflows/ci.yml@@ -94,8 +94,6 @@ jobs:if: ${{ startsWith(github.event_name, 'pull_request') }}run: |cassette_branch="${{ github.event.pull_request.user.login }}-${{ github.event.pull_request.head.ref }}"- git config --global user.name "Auto-GPT-Bot"- git config --global user.email "[email protected]"cd tests/Auto-GPT-test-cassettesif git ls-remote --exit-code --heads origin $cassette_branch ; then@@ -110,6 +108,9 @@ jobs:echo "Could not merge upstream changes to cassettes. Using cassettes from ${{ github.event.pull_request.base.ref }}."git merge --abortgit checkout ${{ github.event.pull_request.base.ref }}++ # Delete branch to prevent conflict when re-creating it+ git branch -D $cassette_branchfiecho "cassette_branch=$(git branch --show-current)" >> $GITHUB_OUTPUTelse@@ -144,17 +145,20 @@ jobs:- id: setup_git_authname: Set up git token authenticationrun: |- base64_pat=$(echo -n "pat:${{ secrets.PAT_REVIEW }}" | base64 -w0)+ git config --global user.name "Auto-GPT-Bot"+ git config --global user.email "[email protected]"+config_key="http.${{ github.server_url }}/.extraheader"+ base64_pat=$(echo -n "pat:${{ secrets.PAT_REVIEW }}" | base64 -w0)+git config "$config_key" \"Authorization: Basic $base64_pat"- cd tests/Auto-GPT-test-cassettes+ cd tests/Auto-GPT-test-cassettesgit config "$config_key" \"Authorization: Basic $base64_pat"+echo "config_key=$config_key" >> $GITHUB_OUTPUT- git config --global user.name "Auto-GPT-Bot"- git config --global user.email "[email protected]"- name: Push updated challenge scoresif: github.event_name == 'push'@@ -172,7 +176,7 @@ jobs:- id: push_cassettesname: Push updated cassettesrun: |- if [[ "${{ startsWith(github.event_name, 'pull_request') }}" = "true" ]]; then+ if [ "${{ startsWith(github.event_name, 'pull_request') }}" = "true" ]; thenis_pull_request=truecassette_branch="${{ github.event.pull_request.user.login }}-${{ github.event.pull_request.head.ref }}"cassette_source_branch="${{ steps.checkout_cassettes.outputs.cassette_branch }}"@@ -183,27 +187,27 @@ jobs:ficd tests/Auto-GPT-test-cassettes- git fetch origin+ git fetch origin $cassette_source_branch:$cassette_source_branch# Commit & push changes to cassettes if any- if ! git diff --quiet; then- if ! [ "$cassette_branch" = "$cassette_source_branch" ]; then+ if ! git diff --quiet $cassette_source_branch --; then+ if [ "$cassette_branch" != "$cassette_source_branch" ]; thengit checkout -b $cassette_branchfigit add .git commit -m "Auto-update cassettes"if [ $is_pull_request ]; then- git checkout -b $cassette_branch || git checkout $cassette_branch- git push -f origin $cassette_branch- cd ../..+ git push --force origin HEAD:$cassette_branch+ else+ git push origin HEAD:$cassette_branch+ fi+ cd ../..+ if [ $is_pull_request ]; thengit fetch origin $base_branchcassette_diff=$(git diff origin/$base_branch)else- git push origin HEAD:$cassette_branch- cd ../..-git add tests/Auto-GPT-test-cassettesgit commit -m "Update cassette submodule"git push origin HEAD:$current_branch@@ -219,8 +223,10 @@ jobs:fi- name: Post Set up git token auth+ if: steps.setup_git_auth.outcome == 'success'run: |- git config --unset "${{ steps.setup_git_auth.outputs.config_key }}"+ git config --unset-all '${{ steps.setup_git_auth.outputs.config_key }}'+ git submodule foreach git config --unset-all '${{ steps.setup_git_auth.outputs.config_key }}'- name: Apply or remove behaviour change label and comment on PRif: ${{ startsWith(github.event_name, 'pull_request') }}