Skip to content

Commit

Permalink
Hotfix to develop to fix the update_truth.yml workflow logic. This te…
Browse files Browse the repository at this point in the history
…sting workflow run failed (https://github.com/dtcenter/MET/actions/runs/9209471209). Here we switch to a unique update truth branch name to avoid conflicts.
  • Loading branch information
JohnHalleyGotway committed May 23, 2024
1 parent cd2b429 commit 66dca0d
Showing 1 changed file with 23 additions and 7 deletions.
30 changes: 23 additions & 7 deletions .github/workflows/update_truth.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,30 +32,46 @@ jobs:
fetch-depth: 0
token: ${{ secrets.METPLUS_BOT_TOKEN }}
- name: Resolve conflicts between branch and branch-ref
id: resolve_conflicts
run: |
branch_name=${{ env.branch_name }}
cd ${GITHUB_WORKSPACE}
if [[ -z "$(git ls-remote --heads origin ${branch_name}-ref)" ]]; then
echo ERROR: ${branch_name}-ref does not exist
exit 1
fi
echo ${branch_name}-ref does exist -- update it
git config --global user.name "metplus-bot"
git config --global user.email "[email protected]"
# checkout branch (develop or main_vX.Y)
echo git checkout ${branch_name}
git checkout ${branch_name}
echo git checkout -b update_truth_for_${branch_name}
git checkout -b update_truth_for_${branch_name}
# merge -ref branch into branch (favoring branch changes)
echo git merge -s ours origin/${branch_name}-ref
git merge -s ours origin/${branch_name}-ref
echo git push origin update_truth_for_${branch_name}
git push origin update_truth_for_${branch_name}
# push changes to branch (develop or main_vX.Y)
echo git push origin ${branch_name}
git push origin ${branch_name}
# create unique branch name to update *-ref branch
update_branch=update_${branch_name}_$(uuidgen | cut -d "-" -f1)
echo "update_branch=${update_branch}" >> $GITHUB_OUTPUT
# create update branch from branch (develop or main_vX.Y)
echo git checkout -b ${update_branch}
git checkout -b ${update_branch}
echo git push origin ${update_branch}
git push origin ${update_branch}
- name: Create Pull Request
run: gh pr create --base $BASE --body "$BODY" --title "$TITLE"
run: gh pr create --head $HEAD --base $BASE --body "$BODY" --title "$TITLE"
env:
GH_TOKEN: ${{ github.token }}
HEAD: ${{ steps.resolve_conflicts.outputs.update_branch }}
BASE: ${{ env.branch_name }}-ref
BODY: ${{ github.event.inputs.change_summary }}<br/>Created by @${{ github.actor}}
BODY: ${{ github.event.inputs.change_summary }}<br/>Created by @${{ github.actor }}
TITLE: Update ${{ env.branch_name }}-ref after ${{ github.event.inputs.pull_requests }}

0 comments on commit 66dca0d

Please sign in to comment.