try using skip ci to avoid re-migrating

This commit is contained in:
Collin M. Barrett 2020-02-16 12:56:07 -06:00
parent 7131b21b49
commit 0e4c86e23c

View file

@ -30,26 +30,25 @@ jobs:
git clone "$FORKURI" .
git checkout "$SYSTEM_PULLREQUEST_SOURCEBRANCH"
# TODO: possibly eliminate: https://docs.microsoft.com/en-us/azure/devops/pipelines/scripts/git-commands?view=azure-devops&tabs=yaml#how-do-i-avoid-triggering-a-ci-build-when-the-script-pushes
- task: Bash@3
displayName: abort if just migrated
env:
GITHUBNAME: $(GITHUBNAME)
inputs:
targetType: inline
script: |
LASTAUTHOR=$(git log -n 1 --pretty=format:"%an")
LASTMSG=$(git log -n 1 --pretty=format:"%s")
if [[ $LASTAUTHOR == "$GITHUBNAME" ]] && [[ $LASTMSG == "migrate PR #$SYSTEM_PULLREQUEST_PULLREQUESTNUMBER" ]] ; then
echo "Just migrated. Aborting..."
else
echo "##vso[task.setvariable variable=required;isOutput=true]true"
fi
# - task: Bash@3
# displayName: abort if just migrated
# env:
# GITHUBNAME: $(GITHUBNAME)
# inputs:
# targetType: inline
# script: |
# LASTAUTHOR=$(git log -n 1 --pretty=format:"%an")
# LASTMSG=$(git log -n 1 --pretty=format:"%s")
# if [[ $LASTAUTHOR == "$GITHUBNAME" ]] && [[ $LASTMSG == "migrate PR #$SYSTEM_PULLREQUEST_PULLREQUESTNUMBER [skip ci]" ]] ; then
# echo "Just migrated. Aborting..."
# else
# echo "##vso[task.setvariable variable=required;isOutput=true]true"
# fi
- job: AddMigration
displayName: add migration
dependsOn: IsMigrationRequired
condition: and(eq(variables['IsMigrationRequired.required'], 'true'), succeeded())
# condition: and(eq(variables['IsMigrationRequired.required'], 'true'), succeeded())
steps:
- checkout: none
@ -86,7 +85,7 @@ jobs:
echo "$MIGLIST"
if [[ $MIGLIST == *$SYSTEM_PULLREQUEST_PULLREQUESTNUMBER ]] ; then
echo "A migration already exists for PR #$SYSTEM_PULLREQUEST_PULLREQUESTNUMBER. Reverting..."
REVERTHASH=$(git log -n 1 --author="$GITHUBNAME" --grep="migrate PR #$SYSTEM_PULLREQUEST_PULLREQUESTNUMBER" --pretty=format:"%H")
REVERTHASH=$(git log -n 1 --author="$GITHUBNAME" --grep="migrate PR #$SYSTEM_PULLREQUEST_PULLREQUESTNUMBER [skip ci]" --pretty=format:"%H")
git revert --no-edit "$REVERTHASH"
fi
@ -124,7 +123,7 @@ jobs:
echo "No-op migration. Effective EF migrations add/change 3 files total (.Designer.cs, .cs, and *ModelSnapshot.cs). Abandoning..."
else
git add .
git commit -m "migrate PR #$SYSTEM_PULLREQUEST_PULLREQUESTNUMBER"
git commit -m "migrate PR #$SYSTEM_PULLREQUEST_PULLREQUESTNUMBER [skip ci]"
echo "##vso[task.setvariable variable=added;isOutput=true]true"
fi