From c424cdea8a5f998fd5141ce8473bc90ea4a168b7 Mon Sep 17 00:00:00 2001 From: "Collin M. Barrett" Date: Wed, 12 Feb 2020 18:09:37 -0600 Subject: [PATCH] re-order migrate step params for clarity --- server/azure-pipelines.migrate.yaml | 45 ++++++++++++++--------------- 1 file changed, 22 insertions(+), 23 deletions(-) diff --git a/server/azure-pipelines.migrate.yaml b/server/azure-pipelines.migrate.yaml index c9444350a..d071851d7 100644 --- a/server/azure-pipelines.migrate.yaml +++ b/server/azure-pipelines.migrate.yaml @@ -17,21 +17,21 @@ steps: - checkout: none # TODO: Replace $(System.PullRequest.SourceRepositoryUri) with fork's URI. https://stackoverflow.com/q/60188806/2343739 - - script: | + - displayName: checkout source branch + script: | git clone $(System.PullRequest.SourceRepositoryUri) . git checkout $(System.PullRequest.SourceBranch) - displayName: checkout source branch # TODO: validate author of last commit was $(GITHUBNAME) - - bash: | + - displayName: abort if just migrated + name: abortIfJustMigrated + bash: | LASTMSG=$(git log -n 1 --pretty=format:"%s") echo "Last commit message: \"$LASTMSG\"" if [[ $LASTMSG == "migrate PR #$SYSTEM_PULLREQUEST_PULLREQUESTNUMBER" ]] ; then echo "Just migrated. Exiting..." echo "##vso[task.setvariable variable=aborted;isOutput=true]true" fi - displayName: abort if just migrated - name: abortIfJustMigrated - task: UseDotNet@2 displayName: use latest dotnet sdk @@ -39,21 +39,23 @@ steps: version: 3.x condition: and(ne(variables['abortIfJustMigrated.aborted'], 'true'), succeeded()) - - script: dotnet tool install -g dotnet-ef - displayName: install ef dotnet tool + - displayName: install ef dotnet tool + script: dotnet tool install -g dotnet-ef condition: and(ne(variables['abortIfJustMigrated.aborted'], 'true'), succeeded()) - - bash: | - git config --global user.name "$GITHUBNAME" - git config --global user.email "$GITHUBEMAIL" - displayName: git config + - displayName: git config env: GITHUBNAME: $(GITHUBNAME) GITHUBEMAIL: $(GITHUBEMAIL) + bash: | + git config --global user.name "$GITHUBNAME" + git config --global user.email "$GITHUBEMAIL" condition: and(ne(variables['abortIfJustMigrated.aborted'], 'true'), succeeded()) # TODO: additionally grep on author of $(GITHUBNAME) when getting $REVERTHASH - - bash: | + - displayName: revert any existing migration for PR + workingDirectory: server/src + bash: | MIGLIST=$(dotnet ef migrations list -p FilterLists.Data.Migrations -s FilterLists.Api) echo "$MIGLIST" if [[ $MIGLIST == *$SYSTEM_PULLREQUEST_PULLREQUESTNUMBER ]] ; then @@ -63,18 +65,16 @@ steps: else echo "No migration exists yet for PR #$SYSTEM_PULLREQUEST_PULLREQUESTNUMBER." fi - displayName: revert any existing migration for PR - workingDirectory: server/src condition: and(ne(variables['abortIfJustMigrated.aborted'], 'true'), succeeded()) # TODO: Merge latest data/* and server/src/FilterLists.Data.Migrations/* from origin/master. - - - script: dotnet ef migrations add $(System.PullRequest.PullRequestNumber) -p FilterLists.Data.Migrations -s FilterLists.Api - displayName: add migration + - displayName: add migration workingDirectory: server/src + script: dotnet ef migrations add $(System.PullRequest.PullRequestNumber) -p FilterLists.Data.Migrations -s FilterLists.Api condition: and(ne(variables['abortIfJustMigrated.aborted'], 'true'), succeeded()) - - bash: | + - displayName: commit or abandon migration + bash: | DIFF=$(git status -s | wc -l) echo "$DIFF file(s) changed" if (( $DIFF != 3 )) ; then @@ -83,14 +83,13 @@ steps: git add . git commit -m "migrate PR #$SYSTEM_PULLREQUEST_PULLREQUESTNUMBER" fi - displayName: commit or abandon migration condition: and(ne(variables['abortIfJustMigrated.aborted'], 'true'), succeeded()) - - bash: | + - displayName: git push + env: + GITHUBPAT: $(GITHUBPAT) + bash: | git config --global credential.helper store echo "https://$GITHUBPAT:x-oauth-basic@github.com" >> ~/.git-credentials git push origin "$SYSTEM_PULLREQUEST_SOURCEBRANCH" - displayName: git push - env: - GITHUBPAT: $(GITHUBPAT) condition: and(ne(variables['abortIfJustMigrated.aborted'], 'true'), succeeded())