diff --git a/.github/workflows/update.yml b/.github/workflows/update.yml index ec7d77f..cd098db 100644 --- a/.github/workflows/update.yml +++ b/.github/workflows/update.yml @@ -32,6 +32,12 @@ jobs: # Checks-out the repository under $GITHUB_WORKSPACE, so the job can access it - name: Check out repo uses: actions/checkout@v4 + with: + ref: ${{ github.event_name == 'pull_request' && github.head_ref || github.ref_name }} + + - name: Verify checked-out branch + run: | + echo "Checked out branch: $(git rev-parse --abbrev-ref HEAD)" - name: Set up MATLAB uses: matlab-actions/setup-matlab@v2 diff --git a/code/+matbox/+git/deleteGitTag.m b/code/+matbox/+git/deleteGitTag.m new file mode 100644 index 0000000..ca6e166 --- /dev/null +++ b/code/+matbox/+git/deleteGitTag.m @@ -0,0 +1,25 @@ +function deleteGitTag(tagName, projectDirectory) +% deleteGitTag - Delete tag from repository (local and remotely) +% + + arguments + tagName (1,1) string + projectDirectory (1,1) string {mustBeFolder} = pwd + end + + if ~strcmp(pwd, projectDirectory) + currentWorkingDir = pwd; + cleanupObj = onCleanup(@(fn) cd(currentWorkingDir)); + cd(projectDirectory) + end + + %[s,m] = system( '$(git rev-parse --abbrev-ref HEAD) == "main"' ) + + [s1, m1] = system(sprintf("git tag --delete %s", tagName)); + assert(s1==0, 'MATBOX:GitUtility:DeleteTagFailed', ... + 'Failed to delete local tag. Reason: %s', m1); + + [s2, m2] = system(sprintf("git push --delete origin %s", tagName)); + assert(s2==0, 'MATBOX:GitUtility:DeleteTagFailed', ... + 'Failed to delete remote tag. Reason: %s', m2); +end